World: r3wp
[Sound] discussion about sound and audio implementation in REBOL
older newer | first last |
Rebolek 16-Aug-2005 [31] | Pekr yes, external library call can solve it (partially). I have to install some C/C++ SDK and start to learn it again... |
Pekr 16-Aug-2005 [32] | I worked with image data in external library, was not all that difficult. Forget C ++, use C. But then - image data is just repetitive pattern of RGBA values, so maybe working with sound data will be much more difficult ... |
Volker 16-Aug-2005 [33] | Can you write prototype in rebol, and i try my c-skills? |
Rebolek 16-Aug-2005 [34] | sorry, what prototype? |
Pekr 16-Aug-2005 [35] | Syntezar's? |
Volker 16-Aug-2005 [36x2] | that needed c-part, fft. |
i don't know the math, but i may be able to translate rebol to c. | |
Rebolek 16-Aug-2005 [38] | there's fft C library, http://www.fftw.org/ |
Volker 16-Aug-2005 [39] | so you only need stubs? |
Rebolek 16-Aug-2005 [40x3] | but I haven't tried it yet. |
No I probably have to rewrite all my routines to C. I haven't started working on FFT at all. | |
I've got phase-distortion oscillator, FM oscillator, wavetable oscillator and my exponential oscillaor plus four types of filters and it's really time consuming in REBOL | |
Volker 16-Aug-2005 [43] | Can i try t translate that? |
Rebolek 16-Aug-2005 [44] | That should be great |
Volker 16-Aug-2005 [45] | Where to start? |
Rebolek 16-Aug-2005 [46] | you can try this Phase Distortion I wrote yesterday |
Volker 16-Aug-2005 [47] | where do i find it? |
Rebolek 16-Aug-2005 [48x2] | osc: context [ phase: 0 AM: 1 ;Amplitude modulation PWM: 0.5 ;Pulse width modulation DCW: .5 ; phase transition between sine and other wave [0 - 1] wave-length: 400 ;wave-length is sample-rate / frequency - don't wanna have samplerate here algorithms: [ saw [ d: (1 - dcw) / 2 cosine 360 * switch-range ph [ 0 d [ph * (pwm / d)] d 1 [(ph - d / (1 - d)) * pwm + pwm] ] ] square [ d: 1 / max 1e-50 (1 - dcw) cosine 360 * switch-range ph reduce [ 0 .25 [ph * 4 ** d / 4] .25 .5 [(abs ph - .5) * 4 ** d / 4 + .5] .5 .75 [ph * 4 - 2 ** d / 4 + .5] .75 1 [(abs ph - 1) * 4 ** d / 4 + 1] ] ] triangle [ ;triangle is d~.588888 d: 1 - (dcw * .41111) ;1 / max 1e-50 (1 - dcw) cosine 360 * switch-range ph reduce [ 0 .25 [ph * 4 ** d / 4] .25 .5 [(abs ph - .5) * 4 ** d / 4 + .5] .5 .75 [ph * 4 - 2 ** d / 4 + .5] .75 1 [(abs ph - 1) * 4 ** d / 4 + 1] ] ] ] algorithm: 'saw curves: copy [] forskip algorithms 2 [append curves to string! algorithms/1] phaser: func [][ phase-per-byte: 1 / wave-length phase: phase + phase-per-byte if phase > 1 [phase: phase - 1] phase ] wave: func [ ][ ph: phaser do select algorithms algorithm ] |
right here ') | |
Volker 16-Aug-2005 [50] | Thats the right size to refresh my knowledge :) |
Rebolek 16-Aug-2005 [51x5] | PWM should be always 0.5 (it's from some older version) |
it supprots three different waveform (still six missing to recreate my CasioCZ ;) | |
basics are 'phaser function - updates oscillator phase | |
and wave function - produces actual sound | |
with DCW you control shape of waveform. DCW-0 is sine waveform, DCW-1 is (square, saw, triangle) | |
Volker 16-Aug-2005 [56] | where does switch-range come from? |
Rebolek 16-Aug-2005 [57x2] | it's just support function |
switch-range: func [number blk][ foreach [rfrom rto action] blk [ if not number? rfrom [rfrom: get rfrom] if not number? rto [rto: get rto] if all [number >= rfrom number < rto][return do action] ] ] | |
Volker 16-Aug-2005 [59] | Is there a loop around that? |
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. |
older newer | first last |