World: r3wp
[Sound] discussion about sound and audio implementation in REBOL
older newer | first last |
Rebolek 16-Aug-2005 [60x6] | yes there's a loop |
I'm filling a buffer of 256 bytes so I can change parametres in realtime (buffer is filled, GUI works again, I can fiddle with knobs) and then I add buffer's content to some sound [block!] | |
buffer: context [ length: 256 data: make block! length init: does [ data: make block! length ] fill: func [fnc][ init loop length [ insert tail data do fnc data ] ] ] | |
then just >>insert tail sound buffer/data | |
but because there's no difference in speed of integer and FP math in REBOL, everything is done in FP sou it's needed to convert FP to 16-bit integer | |
sou=so | |
Volker 16-Aug-2005 [66] | math with fpu should be comparable in speed today. i try it. |
Rebolek 16-Aug-2005 [67x2] | I'm using this code (and I really hope there's some better solution): >> insert tail sample do rejoin ["#{" skip to-hex to integer! (sample-value + 1) * 32767.5 4 "}"] |
If floating point is fast enough today, it's better to use FP because of resolution | |
Luca 21-Aug-2005 [69] | I know Rebol quite well but I don't know music. Can anybody point me to a white paper/tutorial/newbie docs/samples that explains how to valorize sound/data to play some notes? Thank you. |
Rebolek 22-Aug-2005 [70] | luca: take a look at http://www.rebol.com/docs/sound.html, it's googd start. there are examples how to synthetize simple sine wavew and how to apply some envelope on it. |
Luca 22-Aug-2005 [71] | Thank you, it is exactly what I was looking for. |
Rebolek 23-Aug-2005 [72] | Bob Moog, inventor of famous synthesizers, died at age 71. Sad day for electronic music. http://www.moogmusic.com |
Geomol 23-Aug-2005 [73] | Moog producs: http://www.moogmusic.com/detail.php Amazing! |
Rebolek 8-Sep-2005 [74] | Volker so you're interested what's possible with better sound? Me too. But I can tell you, what is possible with today's sound. This - http://krutek.info/pix/pdsynth.png;))) |
Geomol 8-Sep-2005 [75] | That is soo cool! :-) |
Volker 8-Sep-2005 [76] | Does the sound sound "green" like this? :) |
Rebolek 8-Sep-2005 [77x3] | two or three things still missing: WAV saver, Vibrato and probably something else. At least WAV saver must be finished before release. |
Sounds very green ;)) | |
But it's slow. rebcode! will be great for this | |
Volker 8-Sep-2005 [80] | if you have something to translate to c, tell me. |
Rebolek 8-Sep-2005 [81] | Volker lot of things, really :) I'd like to finish features mentioned above and then translate all computations to C. I'll let you now, thank you. |
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 [104x6] | 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 | |
older newer | first last |