| |
Pex Mahoney Tufvesson
Registered: Sep 2003 Posts: 52 |
44.1kHz 8-bit samples - HowTo
I've written a summary on how to play 8-bit samples at 44.1kHz on the Commodore 64, as I did in the Musik Run/Stop demo. For some of you, it's a good read:
http://www.livet.se/mahoney/index_timeline.php
I'll be putting some source files for you there as well sooner or later.
---
Have a noise night!
http://mahoney.c64.org |
|
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
too simple to be true :)
but how about the playback routine ? it still just dumbly plays X kb of samples, while in the demo there's some tought to it ? isnt there space to add 2 samples of 256 bytes ? then by using code as patterns, select different HI bytes for different sample mixing ? ;) Something for the next demo. |
| |
Mr. SID
Registered: Jan 2003 Posts: 424 |
That's awesome stuff. Would you be able to post the lookup table somewhere in the meantime? |
| |
Perplex
Registered: Feb 2009 Posts: 255 |
Great paper! Even I understood most of it (or at least you managed to make me think I did.)
Can the results of this research help improve the general accuracy of SID emulation as well as emulation of this particular trick, without a great deal of additional effort? |
| |
chatGPZ
Registered: Dec 2001 Posts: 11386 |
Quote:That's awesome stuff. Would you be able to post the lookup table somewhere in the meantime?
very cool, works almost exactly like i assumed :)
i would like to see those test programs so we can throw them at VICE :) |
| |
encore
Registered: Aug 2010 Posts: 67 |
Read the article earlier today, definitely an interesting read. :) One funny thing was (since I've also experimented with SounDemons 1 sid voice-technique the last few days) to read that you had drawn the same conclusions regarding samplerate vs amplitude as I did. :)
Anyway, great discovery. :)
The only part I don't understand is if two following $d418-writes has to be paired values in order to gain a certain sample-amplitude level? In other words, does the samples need to be preprocessed in order for this to work? (and would they sound strange if played backwards?)
If not, and if it's then possible to playback any calculated sample-values, I could definitely see THCM freeing up some cycles in his modplayer to perhaps add some more features. :) |
| |
soci
Registered: Sep 2003 Posts: 480 |
Quote: I've written a summary on how to play 8-bit samples at 44.1kHz on the Commodore 64, as I did in the Musik Run/Stop demo. For some of you, it's a good read:
http://www.livet.se/mahoney/index_timeline.php
I'll be putting some source files for you there as well sooner or later.
---
Have a noise night!
http://mahoney.c64.org
Cool someone measured this out finally ;)
One minor correction: It's only ~6.53 bits more or less based on the number of combinations. Only the digimax version has a full 8 bit resolution. |
| |
lft
Registered: Jul 2007 Posts: 369 |
Quoting encoreThe only part I don't understand is if two following $d418-writes has to be paired values in order to gain a certain sample-amplitude level?
No, the way I understood it is that each written value produces a given amplitude on average. Depending on the previously written value, an error is added. The graphs show that these errors are small compared to the average value, i.e. the standard deviation is small.
It's really cool that Mahoney has managed to output 44.1 kHz sound. But the real beauty of this method is that it can be used to play back loud 6.5 bit samples (if soci's calculations are correct) at any convenient frequency, spending a minimum of cycles and not having to worry about exact timing.
Mixing two or more channels would be easy, as long as the sum is passed through a LUT. That table could of course also do compression and other post-processing. |
| |
MagerValp
Registered: Dec 2001 Posts: 1078 |
Quoting lftBut the real beauty of this method is that it can be used to play back loud 6.5 bit samples (if soci's calculations are correct) at any convenient frequency, spending a minimum of cycles and not having to worry about exact timing.
Yeah, this has me really excited. Add a little delta compression and we're talking a lot of high quality sound. |
| |
Pex Mahoney Tufvesson
Registered: Sep 2003 Posts: 52 |
I've added the SID6581 and 8580 reference measurements, volume tables, C64 source code and binary for measurement program and a Matlab script for generating your own volume tables. It's a 100MB download. Have fun!
http://www.livet.se/mahoney/index_timeline.php
Those tables are ideal for real-time 8-bit mixing routines - like the a cappella part in the demo, which uses THCM's mod replayer - with 12kHz rendering.
Now, quantization is a bad thing. So I didn't first quantize the 44.1kHz samples into 8 bits, and then into the available amplitude levels found with this technique. For instance, the 6581 version of the samples uses 107 different values written into $d418 in the demo.
A fun thing is that audio quality can be further improved by "normal CD techniques" like sigma-delta and dithering, since the quantization noise can be pushed above 17kHz. But, in the demo I only minimized the least-mean-square error for each sample individually.
---
Have a noise night!
http://mahoney.c64.org |
| |
The Human Code Machine
Registered: Sep 2005 Posts: 112 |
@encore What features do you mean for my Protracker replayer? It's feature complete and supports all Protracker commands. Even with SounDemoN's 8 Bit waveform output I'm able to play a full featured Protracker modules @ 7812hz and 4 voices. I'm only limiting the different volumes to 32 and limit the amount of different periods to get more memory for samples and music data. With the new replay method it's even possible to add more voices or higher mixing rates.
The a Cappella part for example uses 3 voices @ 11.718hz with reduced feature set to get better sample quality and some action on the screen.
@lft When using more than one voice we're doing it like you explained. |
| |
soci
Registered: Sep 2003 Posts: 480 |
Quoting Pex Mahoney Tufvesson
Now, quantization is a bad thing. So I didn't first quantize the 44.1kHz samples into 8 bits, and then into the available amplitude levels found with this technique. For instance, the 6581 version of the samples uses 107 different values written into $d418 in the demo.
I didn't notice that there were 3 different versions on the disk. I've only run it on 8580 and that version had 93 values.
Would it improve anything if sustain values other than 15 were used? Long ago I did a ~5 bit digi by using the volume+3off combination where the third channel was set differently to have a better linearity. |
| |
Perplex
Registered: Feb 2009 Posts: 255 |
Has anyone started experimenting on using this technique with a REU? If you fix the C64 address to $D418 you can play a 64kB sample at a whopping 985kHz for about 0.066 seconds. Hmm, not very useful. How about doing single byte transfers with STA $DF01 : BNE *-3 to get ~140kHz for about 2 minutes on a 16MB REU, would that work? (Not that you would hear much difference compared to 44.1kHz, though.) |
| |
algorithm
Registered: May 2002 Posts: 705 |
REU should be forbidden in anything c64 related!
Nice method of staying with the same $d418 method but at increased resolution due to the pre-setup. Would use more cycles than the traditional lda #xx sta $d418 due to translation tables to map the sample data to the converted data to $d418 (Although can pre-convert the data) to save on cycles. |
| |
Perplex
Registered: Feb 2009 Posts: 255 |
Quoting algorithmREU should be forbidden in anything c64 related!
Why? It's not like anyone is forcing you to look at it. |
| |
algorithm
Registered: May 2002 Posts: 705 |
True, but everyone is entitled to their opinions and i have given mine :-) |
| |
encore
Registered: Aug 2010 Posts: 67 |
lft: Thanks for the explanation and really cool that it can be used for realtime calculated samples.
Quoting The Human Code Machine@encore What features do you mean for my Protracker replayer? It's feature complete and supports all Protracker commands. Even with SounDemoN's 8 Bit waveform output I'm able to play a full featured Protracker modules @ 7812hz and 4 voices. I'm only limiting the different volumes to 32 and limit the amount of different periods to get more memory for samples and music data. With the new replay method it's even possible to add more voices or higher mixing rates.
THCM: Ah, nice! In the beta I tried in late 2010 the readme-file stated that for time being it wasn't possible to add frequency or volume commands. But I suppose a lot of progress have happened since then. :) |
| |
WVL
Registered: Mar 2002 Posts: 902 |
Well.. if it's really only 6.5 bit samples, let's say 6 bits, than there's some compression right there already. Let's just store 6 bits, and get the corresponding 8 bit value from the lookuptable. |
| |
Urban Space Cowboy
Registered: Nov 2004 Posts: 45 |
I was interested to read these passages:
Quote:I went back to my own software SID
emulator (similar to reSID, but my own version of it)
Quote:Armed with this new knowledge, and with an updated
SID software emulator
Mahoney, please submit your improvements to the VICE project. Poor little ReSID hasn't had any attention since August last year. :( |
| |
chatGPZ
Registered: Dec 2001 Posts: 11386 |
i second that, give alankila a hand :) |