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


Forums > C64 Coding > Sample audio on C64, how to do a better conversion?
2020-07-17 08:00
zzarko

Registered: Feb 2003
Posts: 30
Sample audio on C64, how to do a better conversion?

Hi all!

Recently I have found about c64kernel and a movie player based on that code that uses 16MB REU as a storage. (https://github.com/vbguyny/c64kernel). Movie is based on Koala image sequences, and audio is 4bit samples, where playing routine is based on codebase64 code (https://codebase64.org/doku.php?id=base%3Anmi_sample_player) There is a manual that describes how to make a movie at
https://github.com/vbguyny/c64kernel/blob/master/doc/HowToMakeA..

Anyway, I wanted to make an automatic conversion from a movie file to format for that player and have come up with this Bash script:
https://bitbucket.org/zzarko/c64movie

For audio conversion I did this: converted audio to 8-bit unsigned raw format, and then extracted higher 4 bits from every byte. The result isn't bad, but it is somewhat worse than what "Wav to digi" program can produce (Wav to Digi). So, my question is what could I do to make audio conversion better?

I know that there are more advanced audio and video player routines by magicians around here (I enjoy watching their work!), but nevertheless, if you have some advice, please tell.

One of conversions I did this way:
https://www.youtube.com/watch?v=LN3y1koqi3A
 
... 7 posts hidden. Click here to view all posts....
 
2020-07-17 21:06
Mixer

Registered: Apr 2008
Posts: 329
Mahoneys Music Run/Stop technical details pdf should have the data IIRC.
2020-07-17 21:59
Durandal

Registered: May 2006
Posts: 29
The Python conversion code we're using for streaming on the Turbo56K BBS, while not specifically taking into account any non linearity of the SID, it does a decent job in most cases.

This code accepts most audio file formats

import librosa
import numpy

y, sr = librosa.load(filename, samplerate, True) #load file

numpy.clip(y, -1, 1, y) #Clip samples
norm = librosa.mu_compress(y, mu=15, quantize=True) #mu-compress and quantize to 16 different values
norm = norm + 8 #offset the samples values
									
bin8 = numpy.uint8(norm) #convert to 8-bit unsigned


bin8 contains 4-bit sample data in the lower nibble of each byte.
2020-07-17 23:51
Krill

Registered: Apr 2002
Posts: 1512
Quoting Durandal
[...]not specifically taking into account any non linearity of the SID[...]
[...]mu_compress[...]
Okay, so my takeaway is that applying μ-law is better than using a linear mapping, no matter if specifically tweaked for SID or not.
2020-07-18 00:07
Groepaz

Registered: Dec 2001
Posts: 9432
My guess would be its just the implied lowpass that "does the job" in this case
2020-07-18 00:17
Krill

Registered: Apr 2002
Posts: 1512
Hmm, lowpass or not is mostly a function of catering to a specific sample frequency (downsampling in this case), not reducing bit depth, i thought?
2020-07-18 00:36
Groepaz

Registered: Dec 2001
Posts: 9432
Sure, that... and perhaps a bit of log compression too, which µ-law basically is.
2020-07-18 23:49
zzarko

Registered: Feb 2003
Posts: 30
Thank you all for answers, and especially to Durandal, his conversion gives better results than mine.

I would like to ask Durandal would it be OK to use his conversion code as part of my script, with given credits of course?
2020-07-19 00:24
Durandal

Registered: May 2006
Posts: 29
Sure you can use it, I wouldn't have posted it otherwise ;)
2020-07-29 22:18
zzarko

Registered: Feb 2003
Posts: 30
Thank you all for the help! Author of VBGuyNY C64 Kernel also made some modifications to the player code, now video loops when it finishes and code is more stable. Conversion script was also updated and cleaned.

Also, all this has made one of my dreams come true - State of the Art on C64 :)

https://www.youtube.com/watch?v=QAf5JsIje2Y
2020-07-30 04:46
Kruthers

Registered: Jul 2016
Posts: 21
Downloaded the examples and OMG! Thought I was the only who knew about Sledge Hammer...
Previous - 1 | 2 - 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
Jammer/TooMany
Yogibear/Protovision
SLC
ptoing
McMeatLoaf
Brittle/Demozoo
Honcho
Guests online: 36
Top Demos
1 Coma Light 13  (9.7)
2 Uncensored  (9.6)
3 Edge of Disgrace  (9.6)
4 Comaland 100%  (9.6)
5 Unboxed  (9.6)
6 The Shores of Reflec..  (9.6)
7 Lunatico  (9.5)
8 Remains  (9.5)
9 NGC 1277 100%  (9.5)
10 C=Bit 18  (9.5)
Top onefile Demos
1 Smile to the Sky  (9.5)
2 Listen to Your Eyes  (9.5)
3 Cuarentenauta  (9.5)
4 MD202006 - Get Well ..  (9.5)
5 Dawnfall V1.1  (9.5)
6 Rewind  (9.5)
7 Instinct  (9.5)
8 Crystal Gazer  (9.5)
9 The Tuneful Eight [u..  (9.5)
10 Bad Boy  (9.5)
Top Groups
1 PriorArt  (9.6)
2 Performers  (9.5)
3 Booze Design  (9.4)
4 Censor Design  (9.4)
5 Fossil  (9.4)
Top Mega Swappers
1 Aslive  (9.4)
2 Calypso  (9.3)
3 Dishy  (9.2)
4 Nightshade  (9.2)
5 R.C.S.  (9.1)

Home - Disclaimer
Copyright © No Name 2001-2020
Page generated in: 0.076 sec.