World: r3wp
[rebcode] Rebcode discussion
older newer | first last |
Rebolek 20-Feb-2007 [1582x3] | you can generate sine wave aproximation faster than using sin func |
some example code (in C, but easy to rewrite): float a = 2.f*(float)sin(Pi*frequency/samplerate); float s[2]; s[0] = 0.5f; s[1] = 0.f; loop: s[0] = s[0] - a*s[1]; s[1] = s[1] + a*s[0]; output_sine = s[0]; output_cosine = s[1] | |
this is much faster than calling SIN | |
Coccinelle 20-Feb-2007 [1585] | Very simple indeed. I will test. |
Rebolek 20-Feb-2007 [1586] | have you seen my Sintezar PM-101 in rebol.org library? maybe it will be interesting for you. I've got rebcode version on my disk, but because rebcode is not part of official rebol, it's not released. if you're interested, i can send you some examples. now i'm rewriting that synth as VST instrument in C(++), it's much faster then :) |
Coccinelle 20-Feb-2007 [1587x2] | No, I will look at now. |
Thanks Rebolek, I reduce the time to produce 6 minutes 44 of music from 20 to 15 second. | |
Rebolek 20-Feb-2007 [1589] | you're welcome. 25x faster, very nice! btw, what are you generating? it's your own synth, or some emulation? It's very interesting for me :) |
Coccinelle 20-Feb-2007 [1590] | It's to emulate the PSG AY-3-8910 Just for the fun and to understand a little about music |
Rebolek 20-Feb-2007 [1591] | oh I see. But I thought AY-3-8910 has 4bit osc. with square and saw waves(plus some combinations), no sine? or does it have same lfo with better resolution and sine wave? don't remember the architecture corectly. |
Coccinelle 20-Feb-2007 [1592x2] | Yes that's right, 3 channel plus one for the noise, and square wave. But it's enough complex to start and understand music generation for me. With a simple parameter, I can switch between square wave or sine wave, it's quiet interresting to listen the difference. |
I put the script here : http://www.rebol.org/cgi-bin/cgiwrap/rebol/view-script.r?script=psg-ay-3-8910-study.r | |
Rebolek 20-Feb-2007 [1594] | that's great Coccinelle! nice to see more and more people using REBOL for audio stuff. Maybe R3 will have the annoying audio-click bug fixed ;) btw, I'm just reading your code, there's [rate: 44200], you probably meant [rate: 44100], taht's default CD sampling frequency |
Gregg 20-Feb-2007 [1595] | If I ever have free time again (not complaining, it's good to have work :-), I was thinking it would be fun to do a dialect for binaural beats, ala SBAGen. |
Coccinelle 20-Feb-2007 [1596x2] | I didn't know for 44'100. I have seen in some script 44'200, that's why I use this value. |
The script detect automaticaly if the VM present or not, that's why the algorithm is twice. I will imagine something to draw the wave also using rebcode, it should be very similar. | |
Gregg 20-Feb-2007 [1598] | 44'100 is correct, as the CD standard anyway. |
Rebolek 20-Feb-2007 [1599x2] | Coccinelle: that's good idea with auto-detection. I was thinking about something simmilar for Sintezar once, auto-switching between rebol version, rebcode version and for /PRO C-library version. But I never wrote it, as nobody's using it anyway :) (I've got all three codes, rebol, rebcode and C-library, but not the autoswitch). |
Gregg that binaural beat thing looks very interesting. I was interested in in ELF (extreme low frequencies) some time ago, but I though you need some pretty expensive equipment for it (as normal speakers cannot play 7Hz wave very well, but after reading a book by V. Marek, I found, that 7Hz frequency can be easily simulated by using one wave of frequency X and second wave of frequency X+7Hz. The 7Hz freq. is then created thanks to modulation, regardless on equipment. It's very interesting, unfortunately I had no time to get deeper into this field. | |
Gregg 20-Feb-2007 [1601] | Yes, interesting, and with good headphones you can get subsoncis; SBAGen even offers boost options, by frequency, so you can tailor the compensation to your equipment. |
Rebolek 20-Feb-2007 [1602] | I've heard that Enya's albums are 'enhanced' by some ELFs, but this may be just some urban legend (the reasoning was something like the music sounds so positive because it's using some brainwaves stuff, but maybe it's all bogus. Actually I bought two MCs from Enya some 10-15 years ago and I cannot expect so wide freq. spectrum from cassette, but the music is still positive enough ;) |
Gregg 20-Feb-2007 [1603] | :-) SBAGen, or some other app, has an analysis utility that will show you the binaural beats embedded in tracks. SBAGen also lets you mix the beats with other sounds, so you could add them to Enya's stuff yourself. :-) |
Maxim 20-Feb-2007 [1604] | can you describe what are binaural beats? |
Gregg 20-Feb-2007 [1605] | Low freq waves, played through headphones, with different "beats" going to each ear; designed to induce/stimulate certain brainwave states or patterns. |
Maxim 20-Feb-2007 [1606x2] | and these modify your mood, for example? |
or make you feel light, or sense gravity, etc? | |
Gregg 20-Feb-2007 [1608] | There are a lot of claims and potential uses. |
Maxim 20-Feb-2007 [1609] | so basically subliminal sound, just like subliminal images. |
Gregg 20-Feb-2007 [1610] | I haven't done deep research, but mainly I view them as something like a "helper" for meditation, self-hypnosis, etc. |
Coccinelle 20-Feb-2007 [1611x3] | There is another script of the PSG AY-3-8910 from Guest2, it's here http://www.rebol.org/cgi-bin/cgiwrap/rebol/view-script.r?script=demo-ay.r His script was my inspiration and is much more nice than mine. But I wanted to understand by myself. |
Question : How does work the barb opcode ? | |
Another question : Is possible to do something like a call within rebcode ? | |
BrianH 20-Feb-2007 [1614x3] | Use the APPLY opcode to get access to any REBOL function. Watch out though: When last I checked, repeated calls to APPLY could crash REBOL - some kind of leak, I guess. |
I forget how many calls were required. | |
APPLY is quite slow as well, at least when compared to rebcode in general. | |
Maxim 20-Feb-2007 [1617x2] | I guess its because of all of tha context navigation which rebocode is freed of. |
darn, why does that damn "o" always get added when I write rebcode quickly.. | |
BrianH 20-Feb-2007 [1619x5] | I think that function calls recurse into the interpreter. |
BRAB is for branch tables like that generated by switch statements in C. Words in the target block are changed by the assembler into integer offsets to their associated label statements. Any other use is only appropriate for compiler-generated rebcode. | |
As for an equivalent to NONE?, SETT might work. | |
Looking back on this group, it seems that the APPLY bug may have been fixed. Also, BRAB is good for use on the results of CMP or SIGN. | |
As for reversing the bits in a byte, have you considered a binary lookup table? | |
Maxim 20-Feb-2007 [1624] | steeve... told you brian was the reference here :-) |
BrianH 20-Feb-2007 [1625] | It's been a while - for some I had to go back and look at my own posts :) |
Maxim 20-Feb-2007 [1626x2] | is rebcode still incapable to lookup objects? |
(still as in... did the last version still have that limitation) | |
BrianH 20-Feb-2007 [1628x2] | That was part of the planned upcoming features, and then they stopped updating it. I recall creating a comprehensive proposal... |
You can still APPLY IN and then GETW or SETW. | |
Maxim 20-Feb-2007 [1630] | rebcode really has to be part of 2.7... if we could just have object lookup, that would allow me try to make a few tests with liquid and mayb optimise so its about 10-30 times faster at managing the dataflow :-) |
BrianH 20-Feb-2007 [1631] | Have you tried it with APPLY IN and such? How is the speed compared to REBOL? |
older newer | first last |