World: r3wp
[Sound] discussion about sound and audio implementation in REBOL
older newer | first last |
Volker 8-Sep-2005 [82] | Thanks :) maybe if you make it ready for c, i could do the rest. means make it use structures, not relying on contexts etc. for the time-critical things. |
Anton 8-Sep-2005 [83] | Mmm.. nice picture... |
Henrik 8-Sep-2005 [84] | kru, would you mind if we use this as a VID showcase in the Wikibook? |
Rebolek 8-Sep-2005 [85] | Henrik why not. But the GUI is not 100% finished so I hope it can be later replaced with better picture. |
Henrik 8-Sep-2005 [86x2] | will see if I can upload it in a few mins. |
uploaded. if you get a new version with a new screenshot, you can upload it yourself, but you need an account to upload images... otherwise throw the link in the wikibook group | |
Ingo 14-Sep-2005 [88] | When I create a sound using Rebol, with 2 channels, is it possible to access the to channels independently? So as to create a stereo effect? |
Rebolek 15-Sep-2005 [89] | You must create sound with stereo effect. Once you insert something to sound:// you lost control and cannot change even the volume. |
Ingo 15-Sep-2005 [90] | OK, is there an example anywhere that shows how to create stereo sound? So far I haven't found one. |
Rebolek 15-Sep-2005 [91x9] | http://www.rebol.com/docs/sound.html#section-7 |
For sound samples with two channels both channels are interleaved, i.e. samples for each channel alternate within the binary. | |
Example based on example in Carl's sound guide: | |
print "Generating sound..." bounceL: #{} bounceR: #{} repeat modulate 20 [ delta: negate log-2 modulate for amplitude 400 1 delta [ for phase 1 360 16 [ val: 128 + to-integer 127 * sine phase val: amplitude * val / 400 append bounceL to-char val append bounceL to-char 400 - val ] ] ] bounce: #{} repeat i 400 [ insert tail bounce bounceL/:i insert tail bounce bounceR/:i ] ; Set up the sound sample parameters: sample: make sound [ rate: 44100 / 2 channels: 2 bits: 8 volume: 0.5 data: bounce ] ; Play the sound now: sound-port: open sound:// insert sound-port sample wait sound-port close sound-port | |
The problem is that it does not work (at least here). | |
And here's why: | |
>> sample/channels == 1 >> sample/channels: 2 == 2 >> insert sound-port sample == 199 >> sample/channels == 1 | |
There's some strange conversion always when you play a sound. | |
Sound is buggy as something really buggy. | |
Pekr 15-Sep-2005 [100] | RAMBO it! |
Rebolek 15-Sep-2005 [101] | Ah there's bug in example, it should be "128 - val" instead of "400 - val" but that's not the problem |
Ingo 15-Sep-2005 [102x2] | Thanks Kru, I reread that part, and actually found Carl's explanation. |
Now that's interesting ... if I paste your example into a console, I get a very short high beep if I paste it into a script and do the script, I get a math error! (Math or number overflow) | |
Rebolek 15-Sep-2005 [104x12] | Ingo: yes there are some bugs ;) |
I didn't test it before pasting it here | |
Wait a minute, I'll post fixed version | |
OK | |
print "Play a ping sound..." ; (init event system too) ; Generate a ping waveform as a binary value: ping: #{} for amplitude 500 1 -1 [ for phase 1 360 16 [ val: 128 + to-integer 127 * sine phase val: amplitude * val / 500 append ping to-char val ;append ping to-char 256 - val ] ] ; Set up the sound sample parameters: sample: make sound [ rate: 44100 / 2 channels: 1 bits: 8 volume: 0.5 data: #{} ] ; Make the ping sound 10 times: loop 10 [append sample/data ping] ; Play the sound now: sound-port: open sound:// insert sound-port sample wait sound-port close sound-port | |
this is mono example - plays ping sound | |
print "Play a ping sound..." ; (init event system too) ; Generate a ping waveform as a binary value: ping: #{} for amplitude 500 1 -1 [ for phase 1 360 16 [ val: 128 + to-integer 127 * sine phase val: amplitude * val / 500 append ping to-char val append ping to-char 256 - val ] ] ; Set up the sound sample parameters: sample: make sound [ rate: 44100 / 2 channels: 2 bits: 8 volume: 0.5 data: #{} ] ; Make the ping sound 10 times: loop 10 [append sample/data ping] ; Play the sound now: sound-port: open sound:// insert sound-port sample wait sound-port close sound-port | |
This is stereo example - plays nothing | |
if you look at sample/data after inserting sample to sound:// they're changed | |
>> sample/data == #{ 827EA55BC53BDF21F30DFD03FE02F40CE21EC838A957867A649C43BD27D911EF 05FB02FE08F818E831CF4FB1718F817EA45BC43BDE21F20DFC03FD02F30C... | |
>> insert sound-port sample == 115000 >> sample/data == #{ 80808080808080808080808080808080808080808080807F7F7F7F7F7F7F7F7F 7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F... | |
Another thing - REBOL sounds different compared to other players. It's noisy and dull. I've got 44100Hz/16bit sound and it sound's more like 22050/8bit to my ear. | |
Pekr 15-Sep-2005 [116x2] | simply put, rebol sound quality and buggy behavior deserves to be put into trashcan ;-) |
now let's convince Carl, that as AGG was good choice for vectors, we should find another library for sound. Maybe fmod? | |
Rebolek 15-Sep-2005 [118] | fmod? why not. but who's going to pay the license? |
Pekr 15-Sep-2005 [119x2] | RT's investor? :-) First I would try to talk to those folks, then to speculate about how much it will be. Maybe there is some amigan inside the group :-) |
the question is - AGG for vectors, is one of two best free libraries - Cairo and AGG ... so - how is fmod quality wise? Is there any better, smaller library to have? | |
Ingo 15-Sep-2005 [121x2] | It seems sound data is only changed on first insert, though. |
Btw, I get different values, and the stereo version plays a sound for me | |
Rebolek 15-Sep-2005 [123x2] | Probably depends on sound hardware, because I've testing this previously and I was getting different results on my home computer and my work computer |
Anyway, I think it's bad behaviour. The data should remain same (the can be changed internaly when playing but users must see same data). | |
Ingo 15-Sep-2005 [125x2] | Yes, that may be the case. |
Well, whatever, sound in Rebol seems to be more or less unusable. | |
Romano 15-Sep-2005 [127] | Here under XP and REBOL/View 1.3.1.3.1, both example (mono and stereo) work, 2 sample/data is not changed after insert. |
Rebolek 15-Sep-2005 [128x4] | Romano I think it does not depend on system version but on soundcard (or drivers probably) |
REBOL does definitely play sounds in 22kHz/8bit. You can hear the quantisation noise in low volume and everything sounds so filtered. | |
I've got some Intel chipset soundcard in work, but here at home I've got M-Audio Delta 1010LT and the results are same (sound results, sample/data looks different). | |
It's really problem, but on the other hand, I can hear that Sintezar is much much better with sound than I thought on listening test done in REBOL :) | |
older newer | first last |