Jump to content
IGNORED

large audio clips


ZackAttack

Recommended Posts

For a basic experiment, I ripped the Boulder Dash music code and created a simple ROM from it. Attached you find the source code and two variations. One updates AUDV0 and AUDV1 at 100% equal intervals, while the other one (7) randomly delays the updates between 0 and 7 cycles.

 

At least for this example, I cannot hear any difference. So probably I was wrong, and the update timing is not that critical.

Me neither.

Try a sine wave,you'll hear warbling I bet.

 

Link to comment
Share on other sites

Don't think this requires filtering out at twice nyquist frequency, as 60*292 = 15,720 hz, which is the upper limits of most basic audio playback devices anyways, so most sounds recordings (especially from the 1980s, probably had that in mind).

The Nyquist frequency is half of the sample rate, 7860Hz in this case. I downloaded the same Back To The Future clip from youtube yesterday. Here's Audacity's spectrum report for my clip...

 

post-23476-0-99156400-1512923709.png

 

Everything above 7860Hz won't get the two sample points necessary to represent a sine wave, and will add to noise.

  • Like 2
Link to comment
Share on other sites

Could the second volume register be used to change the loudness of each frame? Then you'd only have to set it once per frame. I think that would work pretty well for video playback.

Well, we're talking about AUDC#=0, where a DC offset is output instead of a frequency. In this case, if the second volume register has a value that isn't changing between frames, then it's just an unchanging DC offset, which doesn't amplify the other channel. At some point in the audio chain a capacitor will filter the DC offset out, but even if the DC offset did make it through the chain, it would push the speaker cone out a certain distance and hold it there. Other than that initial push to get to the position, there would be no additional movement of air, so no change in the overall volume.

 

That initial push, and any other frame-based changes, will just create a small 60Hz "thump", with volume of the thump in proportion to the size of the change.

  • Like 2
Link to comment
Share on other sites

What kind of dithering? Random?

I'd be most interested in the details too, though I don't think dither will help much until non-linear samples are implemented.

 

Here are the graphs of 4-bit and 5-bit TIA audio output levels, vs linear output.

 

post-23476-0-88895700-1512945491.png

post-23476-0-43759700-1512945498.png

 

Dithering is meant to cover up patterns due to rounding errors, and will "correct" up to 1/2 the amplitude of the lowest bit.

 

In the graphs you can see TIA vs Linear (4-bit) will result in many value errors that are nearly the full amplitude of that lowest bit. This is why I think non-linear inaccuracy is the biggest fish, and adding dither without this fix will (for most values) add the random noise without getting the benefit of covering the errors.

 

The 5-bit graph shows the error is even worse, owing to the increasing rounding that happens as the combined values get higher.

  • Like 2
Link to comment
Share on other sites

What kind of dithering? Random?

The last posted samples, are just quantized to the bit depth (using floor). Using (round) was less audible.

I then introduced some random noise (with even distribution) before quantization, sounded hissy. I think I read the random distribution is supposed to be triangular or something.

I also tried a dithering algorithm I guessed at, where I took the difference and either added it all to the next sample, or split up at various weights over the next 3 samples.

Its mostly guess work on my part so far, so Im sure Im forgetting some important steps.

 

I think PWM or something similar was what my 1990s 1-bit speaker were playing. They were surprisingly clear from what I remember.

 

 

 

 

Link to comment
Share on other sites

I have played around with this some more and built a driver that plays 510k of packed 5bit samples. Attached are two ROMs (again 3E banking) that play an ascending scale starting at 110Hz using a sinus that uses the full sample range from 0 to 30. One file (test_linear) has been created using naive quantization, the other (test_nonlinear) corrects for the TIAs nonlinear response. To my ears, the nonlinear version sounds cleaner, while the linear one exhibits a ringing effect.

 

Note that I have used Stellerator for comparing the two; I haven't yet managed to get those ROMs (or ZackAttack's for that matter) to run on a Harmony encore.

 

My next step will be to write code that resamples and packs a WAV and run this on rbairos 8bit samples for comparison. As a reference, I have attached the driver (assembles to 2k that go into the last bank aka the last two kb of the 512kb image) and a dirty piece of javascript (run with NodeJS) that generates the sample data. I'll be writing a proper tool to convert the WAVs, but the JS documents the (hopefully correct) algorithms I've used :)

 

EDIT: If you want to play with the playback driver yourself, note that the first three bytes of each bank (=2048 byte block) are ignored, so there is room for 2045 * 255 * 8 / 5 = 834360 samples before it loops.

test_linear.bin

test_nonlinear.bin

driver.asm

driver.bin

generator.js.zip

Edited by DirtyHairy
  • Like 3
Link to comment
Share on other sites

Note that I have used Stellerator for comparing the two; I haven't yet managed to get those ROMs (or ZackAttack's for that matter) to run on a Harmony encore.

Harmony doesn't support larger 3E roms. You have to make it 32k and give it a .3e extension to playback on harmony. Eventually I'm going to enable playing back samples from the SD card and then we can really have some long audio clips.

  • Like 1
Link to comment
Share on other sites

The Harmony Encore supports up to 512K, most likely the 3E driver needs to be updated.

 

That's what the website says, but do you know of any 512KB roms that actually work on it?

 

Either way it's probably best to just read in the data directly from a file on the SD card. Then you can have up to 4GB in a single file.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...