World: r3wp
[rebcode] Rebcode discussion
older newer | first last |
Steeve 18-Feb-2007 [1550x3] | seems not |
so, i have to do something like that, to set the T flag, i mean : AND tmp 255 eq.i tmp 255 | |
i have to do many operations like that to emulate the Z80 8-bit ship, Z80 modify his T-flag after any logical operation. i think Rebcode should do that too :-) | |
Oldes 18-Feb-2007 [1553] | Please write it to Rambo, better now, before R3 |
Steeve 18-Feb-2007 [1554x5] | done |
another prob is that all opcode operate on 32 bit integers only, in my case it would be cool if they can act as well on chars (8 bit) | |
i can do without, but my code is more verbose | |
...and slower | |
espacially with bit rotation opcode, which are useless in my case ^^^ | |
Steeve 19-Feb-2007 [1559x2] | i need a speed reverse byte function with rebcode , for example 1100 0000 => 000 0011 any idea ? |
* 1100 0000 => 0000 0011 | |
Coccinelle 20-Feb-2007 [1561] | I get strange result from the sin opcode, is there something special to know or is it a bug ? |
Maxim 20-Feb-2007 [1562] | rad or degres? |
Coccinelle 20-Feb-2007 [1563x2] | degree |
I try with rad too but I should make a mistake | |
Maxim 20-Feb-2007 [1565] | I'm not an expert only that I know by having many 3d cgi scripts that many apis have a mix and match of rad and degres... but it seems you looked at that too... |
Coccinelle 20-Feb-2007 [1566x3] | To test, I use this code : |
test-sin: rebcode [value [decimal!]][sin value return value] | |
>> test-sin 90. == 0.893996663600558 >> test-sin 100. == -0.506365641109759 >> test-sin 0.0 == 0.0 >> test-sin 1. == 0.841470984807897 >> test-sin .1 == 9.98334166468282E-2 >> | |
Maxim 20-Feb-2007 [1569x2] | hum... its possible that some values just don't map directly to precise values (floating point errors) |
but I agree that sin 90 should give you something closer to 1 | |
Coccinelle 20-Feb-2007 [1571x2] | et sin 1 devrait donner quelque chose de proche de 0 |
sorry in english, and sin 1 should give something near to 0 | |
Maxim 20-Feb-2007 [1573x2] | just tested and well... the values supplied really are in radians :-) |
>> sine/radians 90 == 0.893996663600556 | |
Coccinelle 20-Feb-2007 [1575] | and a radian is pi / 2, right ? |
Maxim 20-Feb-2007 [1576] | 2 * pi |
Coccinelle 20-Feb-2007 [1577x2] | Yes, right. It's OK now my script is running well. Thanks you. |
Thanks to rebcode I can generate 6 minutes of music in 20 seconds instead of 5 minutes with a standard script. Great. | |
Rebolek 20-Feb-2007 [1579x2] | if you want fast sine, use tables, it's 10x times faster (that's without interpolation, but even with interpolation it will be still faster). |
or if you need continuos sine wave, use self oscilating filter | |
Coccinelle 20-Feb-2007 [1581] | I'm a newbe in music generation so ... I don't know what is self oscilating filter. |
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 [1599] | 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). |
older newer | first last |