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 Composing > Portamento Routine
2007-07-04 15:34
Necro

Registered: Jun 2007
Posts: 6
Portamento Routine

Hey... I am currently implementing a C64-MIDI interface - got single note working well, filter envelopes.. arps etc.. its starting to sound pretty good! The only thing i need to add now is a good poly mode, and most important, Porta! I have a question to the sid coders out there... whats the fastest way to figure out how to logarithmically add (or subtract) the current note values to get to the destination note? I.E. I detect that C-2 is playing, then you press C-3, I want a constant slide up. Any input would be appreciated!

Thanks.
2007-07-04 17:01
Conrad

Registered: Nov 2006
Posts: 856
Probably the fastest way will be to use two portamento tables, one table for high-byte frequency, the other for low-byte frequency. That way it wouldn't really matter to identify if the portamento is up or down, as $0000-$7fff increases the frequency, and $8000-$ffff decreases the frequency - this is if you are using CLC and ADC for changing the frequency - if you are using SEC and SBC, it will be vice versa. The only thing you'll need to take care of is from which note you will start porta from. For example, if you want to porta from C-2 to C-3, make sure the porta value is somewhere between $0000-$7fff, so that it goes upwards.

Because these values are stored in two seperate 8-bit tables, the midi-sequencer can have a certain command, where it's 8-bit parameter will be the table read position, so that you can have so many different portamento rates (or a maximum of 256) via the tables.

Then as for checking when the porta has reached the target note, you first start by storing the start note frequency in a buffer, use that buffer with porta, and then compare it with the target note frequency. This can obviously be done with the CMP opcodes, where you can use the carry flag to check if the value is greater or less than the target value (BCC and BCS opcodes) Because these are 16-bit values, you will obviously have to do 2 comparisons at the same time, so raster-time use will be an important factor. Don't forget to store the raw frequency of the target note in the buffer as well, because you will most likely have a frequency bug if you are doing portas on low-octave notes. Once the porta is done, simply store the exact target frequency so that you get a nice sharp note.

I would think another way will be to actually subtract the target frequency with the start frequency, where you will get the differece, divided by how long you want the portamento to last, but this is something I have not tried before, thinking that this might be more work and could use more rastertime.
2007-07-15 20:58
Necro

Registered: Jun 2007
Posts: 6
Hmm, I'm not sure that a custom midi command is in order for this... really I have a 127 byte note table, these are the active notes, no matter what mode (poly, arp etc) its in. I figure if I detect that I've gotta go from a C-2, to a C-3 how can I easily calculate what values to add to the frequency for a smooth porta?

Thanks
2007-07-16 07:15
Frantic

Registered: Mar 2003
Posts: 1661
A custom table (or tables) is the easiest way I guess, in case you got enough memory. You can also abuse the standard freq table used for notes in various ways (since that has the logaritmic character needed too). Not very informative, I guess, since you actually asked for examples and so on. However, the actual implementation would depend a little on the details. Do you want selectable speed, or only one portamento speed?

Just dividing the "distance" in X steps will not do if you're picky, since the sweep values should be logaritmic aswell to be really correct.
2007-07-16 11:24
Conrad

Registered: Nov 2006
Posts: 856
I believe the division way will be the one for Necro to use due to the current features he has for the player, yet this might not be the fastest way as you need to include some algorithms for 8-bit division (check Codebase64 for articles on how to do this.)

Also division may be more difficult (or more algorithm needed) if you are dividing with values that are not power of 2, such as 3, 5, 7, etc, since you divide the porta rate with value known as duration of the porta active.
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
Brataccas/HF
bugjam
Barfly/Extend
Didi/Laxity
MCM/ONSLAUGHT
bepp/ΤRIΛD
Guests online: 408
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Codeboys & Endians  (9.7)
4 Mojo  (9.6)
5 Coma Light 13  (9.6)
6 Edge of Disgrace  (9.6)
7 Signal Carnival  (9.6)
8 Wonderland XIV  (9.5)
9 Uncensored  (9.5)
10 Comaland 100%  (9.5)
Top onefile Demos
1 Nine  (9.7)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.5)
6 Scan and Spin  (9.5)
7 Onscreen 5k  (9.5)
8 Grey  (9.5)
9 Dawnfall V1.1  (9.5)
10 Rainbow Connection  (9.5)
Top Groups
1 Artline Designs  (9.3)
2 Booze Design  (9.3)
3 Performers  (9.3)
4 Oxyron  (9.3)
5 Censor Design  (9.3)
Top Fullscreen Graphicians
1 Joe  (9.7)
2 Sulevi  (9.6)
3 The Sarge  (9.6)
4 Veto  (9.5)
5 Facet  (9.5)

Home - Disclaimer
Copyright © No Name 2001-2025
Page generated in: 0.04 sec.