Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > How to players and trackers usually deal with these modulation issues? --> Bit-scaling? (sid related, but not nescesarily, not a question related to the battlestar galactica music btw;-)
2006-07-19 22:37
stunt
Account closed

Registered: Jul 2006
Posts: 48
How to players and trackers usually deal with these modulation issues? --> Bit-scaling? (sid related, but not nescesarily, not a question related to the battlestar galactica music btw;-)

hi all!

I use the output of osc3(8bit) ($d41b) to modulate the pulsewidth osc1 (12bit) ($d402 & $d403), but now i still do that by just modulating OR the lobyte OR the hibyte register which gives very coarse results and also causes the modulation not to be active on the whole scale of the parameter.

I want to improve this situation so i came up with two strategies, and i'd like to hear your comments on them.

Ok. let's take a look at the situ:

The 8 lsbs reside in d402, the 4 msbs are bits 0,1,3 & 4 of $d403.

Ofcourse I want to spend as less time as possible doing the math.

Now I thought of two strategies:

Strategy 1: To modulate just the 8 most sig. bits of the 12bit word. That would mean to split the modulator byte in two and use the 4 most sig bits to modulate the 4 least sig bits of $d403, and to take the other 4 bits and use them to modulate the 4 most sig bits of $d402.

pros: prolly a time efficient solution
cons: coarse way of modulating: takes 16 steps at a time.

Strategy 2: to "bitscale" or strech up the 8bit modulator value up to a 12 bit value and modulate the 12 bits.

pros: more detailled modulation
cons: prolly lot of math and thus time consuming.

My question: what would be the most time efficient ways to implement both strategies, and which strategy would you guys advice me.

How do players and trackers usually deal with the 12bit wide pulsewidth modulation?

Ofcourse i also want to modulate the 16 bit pitch, the 11 bit filtercutoff and the 4 bit volume parameters.

so i'd like to see a solution for the stretching to all these.

so :

8 bit value modulates 4 bit value
8 bit value modulates 16 bit value
8 bit value modulates 12 bit value
8 bit value modulates 11 bit value

i can imagine dat streching up and down to 4 or 16 is less difficult and strechting up to 11 is the hardest to do. is my intuition right?

very interested to see your solutions to my problem.

And prolly my most important question:

How do players and trackers usually deal with these modulation issues?

Greetz,

Stunt
 
... 16 posts hidden. Click here to view all posts....
 
2006-07-20 13:09
stunt
Account closed

Registered: Jul 2006
Posts: 48
Quote: you dont need to and #$fe I guess. 2 tables should work out aswell, giving more detail.

ldx $d41b
lda pw_low,x
sta $d402
lda pw_hi,x
sta $d403

frankly, Im not a sidprogramming expert at all, I've been told that its better to collect all parameters, store them, and next frame write them to sid. Doing these inbetween sidwrites might make it jitter, I think.

You're bount to loose detail, because you spread your 8bits over 12bits. Maybe there's a skilled programmer who can do a routine that calculates the in between values, but with a noise waveform modulator, it might be a bit tricky to calculate the correct value. (Or just take a random one. :)

I think this $d41b thing ain't made for pw-modulation, not even filter-modulation, despite of what the manual says. The manual never said anything about open sideborders. It's better to have your own routine doing the modulation. (like Laxity and Cadaver stated)


I figured that in hein's first example he had an interleaved table in mind (table .byte hi,lo,hi,lo, etc)that provided the same amount of detail as two seperatate tables for hi and lo. Is there a difference in detail between two options?

And yes, i will loose detail when i streched 8 bit to 11,12 and 16 bit, but still the modulation will have a 8bitresolution so that's pretty funky if you ask me. Interpolation will indeed provide even smoother modulation but requires realtime math and will prolly cost too much time. Even the streching without interpolation will prolly be quite cpu intensive, altough i'd love to see some expert coder comming up with some lean realtime bitscaling code!
2006-07-22 14:43
stunt
Account closed

Registered: Jul 2006
Posts: 48
So, did none of you coders ever adress the problem of bitscaling?

2006-07-22 17:44
Laxity

Registered: Aug 2005
Posts: 459
lda $d41b
pha
asl
asl
asl
asl
sta $d402
pla
lsr
lsr
lsr
lsr
sta $d403
2006-07-22 17:57
stunt
Account closed

Registered: Jul 2006
Posts: 48
@laxity: ok. that's strategy 1. briliant. thxalot.
2006-07-22 18:08
stunt
Account closed

Registered: Jul 2006
Posts: 48
now for strategy 2, tables would be a solution.
so for every of the $ff steps, to enlist in table two corespondend bytes (hi and lobyte) and precalulate those values for 11,12 and 16 bit values.

But my intuition tells me there must be smarter (calculated) ways, for example to scale an 8 bit byte to a 16 bit word seems easy:

11111111 would become 11111111 11111111
00001111 would become 00000000 11111111
10101010 would become 11001100 11001100

right?

so it means taking bits 8, put it on both
bit 8 and 7 of the hibyte of the word,
take bit 7, put in on bit 6 and 5 of the word.
etc.

what would te most elegant way in asm to do that?

----

now getting from a byte to a nibble seems easy too:

create the nyble out of bits 8 6 4 and 2 of the byte.

any suggestions for how to do that in asm?

----

but getting from byte to 11 and 12 bit words seems the hardest to me...

any elegant (calculated) sollutions?

Thx.

Stunt
2006-07-22 18:22
Laxity

Registered: Aug 2005
Posts: 459
I get your method, but how would you go about scaling from 8 to 12 bit in that way?.. Anyway, I think the result of the "bit streching" (and loss of resolution) will be A LOT more audiable than disregarding the 4 least significant bits of the pulse width as they are indeed the least significant bits ;).
2006-07-22 19:16
stunt
Account closed

Registered: Jul 2006
Posts: 48
Quote: I get your method, but how would you go about scaling from 8 to 12 bit in that way?.. Anyway, I think the result of the "bit streching" (and loss of resolution) will be A LOT more audiable than disregarding the 4 least significant bits of the pulse width as they are indeed the least significant bits ;).

scaling from 8 to 11 or 12 bits,
that was exactly my question :-)
hoped some genius would come up with a solution for that:-)

and about the resoltion : is that so are you rigth about that?

hmm...
2006-07-22 19:29
tlr

Registered: Sep 2003
Posts: 1724
Quote: scaling from 8 to 11 or 12 bits,
that was exactly my question :-)
hoped some genius would come up with a solution for that:-)

and about the resoltion : is that so are you rigth about that?

hmm...


Laxity is correct.
Shifting (=multiplying) is the way to convert an 8-bit number to a different number of bits.
Your way is might make sense for something visual, but for mathematics, it's just strange. :)
2006-07-25 14:24
stunt
Account closed

Registered: Jul 2006
Posts: 48
Ok thx. u guys are right. Hein and laxity thx for the code.

Now the next challenge. Take the example of vibrato (but i'd like to come with similar appraoches for modulation of all paramters like cutoff pulsewith, volume etc):

Ofcourse there has to be a centre value to which vibrato has to be apllied. That means the modulationvalue has to be inverterd and subtracted to the played pitch value when it is 127 or lower, or subtracted by 127 and added to the played pitch value if it's 128 and higher, right? (because 127/128 is like the zero of the goniometric modulation figure, and values of 127 represent negative modulation, and 128 and above represents positive modulation).

On top of that, ofcourse there has to be something like 'vibrato dept'. (in the world of 'normal' synthesis) this comes down to mupliplying the modulationvalue with the dept-value. So when dept is 0, the modulation will be 0, and when dept is max, the modluation will have a radius of +/-128.

This last thing i figured could easily be done by having a 3bit modulationdept that makes the modulationvalue be devided by 2 ("ror a"-ed) 1 to 8 times depending on the value of the modulation dept. This is already working but i was wondering wether you guys had a better solution that has nmore then 8 steps and that is linear instead of exponential.

For the first thing i really don't know how to do this so i hope you guys can help me (i'm still not good at math in asm). Ok here's my plan, hope you can help me implement it/transfer it to code:

1. Read the modulationvalue (can be osc3,env3 or value from a osc- or env-table)
2. If value is 127 or lower, then:
-Invert it (so 127 becomes 1, 126 becomes 2 , ... , 1 becomes 127, 0 becomes 128)
-Create an adress and use one bit as an add/subtract flag, and set it to 'subtract'.
3. If value is 128 or higher, then:
-Subtract the value by 127
-Create an adress and use one bit as an add/subtract flag, and set it to 'add'.
4. Multiply the 'absolute' modulation with the intensity value.
5. add or subtract (depending on what the flag says) the value with the pitch value.

Ok. esp how to create this "absolute" modulation value i don't know. So plz come with suggestions. Or if this whole thing can be simplified or done more efficient --> REally interested in your sollutions. Thx.

Stunt




2006-07-26 05:14
Jetboy

Registered: Jul 2006
Posts: 227
Sorry but there is beter approach:

When you use bit 7 as a sign you understand values of 0-127 as 0-127, and values of 128-255 as -128 to -1. So 255 is -1, 254 is -2 and so on.

You just do your math as usual (if its one byte long).

There are instructions that support that build into 6502.
There is N flag, standing for negative in status register.
So if bit 7 in acumulator is set the flag is set acordingly.
and there is BMI - Branch if MInus, and BPL - Branch if PLus conditional jumps to support that.

That way steps 2-3 becomes obsolete, and in step 5 you only need just add.

Sorry but i'm totaly green on sound programming so i dont understand fully those modulations and stuff. I dont really know if they are 8 or 16 bit, hence i wont be able to help much more. But if they are 8 bit it should be fairly easy.
Previous - 1 | 2 | 3 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
psych
Guests online: 83
Top Demos
1 Next Level  (9.8)
2 13:37  (9.7)
3 Mojo  (9.7)
4 50 Years of Flex  (9.7)
5 Coma Light 13  (9.7)
6 Edge of Disgrace  (9.6)
7 Comaland 100%  (9.6)
8 Uncensored  (9.6)
9 No Bounds  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 Layers  (9.7)
2 It's More Fun to Com..  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Rainbow Connection  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Booze Design  (9.3)
3 Censor Design  (9.3)
4 Crest  (9.3)
5 Performers  (9.3)
Top Original Suppliers
1 Black Beard  (9.7)
2 Derbyshire Ram  (9.5)
3 hedning  (9.2)
4 Baracuda  (9.1)
5 Jazzcat  (8.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.049 sec.