[Coco] Assembly audio routines

Glen Hewlett glen.hewlett at sympatico.ca
Sun Mar 19 19:41:15 EDT 2017


Hi Ed,

Thanks for the info, I thought that might be how it worked.  So I guess it’s really a matter of quality of sound vs speed of the game at this point.  I’m looking forward to getting some sounds out of my CoCo using assembly language, it sounds pretty straight forward.

I remember reading either on this list or some old forum where someone was saying you can send a byte I think to the PIA and it will set the CoCo to ignore bits 0 & 1 of $FF20 so you don’t have to worry about them and send garbage data to the RS-232 output or the Cassette data input lines.  Does this sound familiar to you?

I’ll see if I can dig it up again.

Your sample playback is amazing sounding from the CoCo.

Cheers,
Glen



> On Mar 19, 2017, at 5:59 PM, Zippster <zippster278 at gmail.com> wrote:
> 
> Hi Glen,
> 
> If you want to play back audio samples on the CoCo (using the DAC I assume), then it’s
> fairly simple.  Format your audio as 8 bit unsigned mono.  Grab a byte at a time and shoot
> it at the DAC $FF20 at whatever your sample rate is.  You’ll have to work the code out to
> write a byte to the DAC at precise intervals (# of cycles).
> 
> That’s really all there is to it for samples using the DAC.  You’ll lose some precision because
> the DAC is 6-bits vs 8, but it can still sound very good depending on your sample rate.
> 
> Playing samples will tie up your code though if you plan to have a lot of other stuff
> going on at the same time, as you have to service the DAC constantly during playback.
> 
> This is audio playing through the 6-bit DAC at 44.5KHz (1 byte every 20 cycles) from
> some code I’ve written that will do continuous playback from the CoCo SDC.
> 
> <https://drive.google.com/open?id=0B1sgl615FlGnNzE3YVRhX3ZnSnM <https://drive.google.com/open?id=0B1sgl615FlGnNzE3YVRhX3ZnSnM>>
> 
> Of course, at this bit rate it ties the system up pretty well at .89MHz.
> 
> - Ed
> 
> 
> 
>> On Mar 19, 2017, at 4:35 PM, Glen Hewlett <glen.hewlett at sympatico.ca> wrote:
>> 
>> Hi Evan,
>> 
>> Thanks for the info, I looked at your code and it will be useful if I want to play tones from the computer like the sound command in DECB.  But what I’m looking for is some code to play back audio samples (PCM audio data) like wav files.  I think this is the only way I can keep the game going at the same time as playing sound effects/music.  As I understand it will take using the FIRQ and sending certain number of sampled bytes every time the FIRQ is triggered.  So it will have to be very optimized code.
>> 
>> Cheers,
>> Glen
>> 
>>> On Mar 19, 2017, at 5:18 PM, Evan Wright via Coco <coco at maltedmedia.com> wrote:
>>> 
>>> Here is the github repository for the CoCo project I recently did.
>>> https://github.com/evancwright/CoCo
>>> 
>>> If you look in floodit_cart.asm there is a routine which plays the intro melody to the game.  I never did get sound working in an unblocking fashion, though,  It looks like the ISR checks the values for the length and freq of the tone to play, then loops until the sound is done playing.
>>> I used this as a reference...http://www.lomont.org/Software/Misc/CoCo/Lomont_CoCoHardware.pdf
>>> 
>>> Hope this is at least somewhat useful.
>>> -Evan
>>> 
>>> 
>>> 
>>> |  
>>> |   
>>> |   
>>> |   |    |
>>> 
>>> |
>>> 
>>> |
>>> |  
>>> |    |  
>>> evancwright/CoCo
>>> TRS-80 CoCo Projects  |   |
>>> 
>>> |
>>> 
>>> |
>>> 
>>> 
>>> 
>>> 
>>>  On Sunday, March 19, 2017 1:34 PM, Glen Hewlett <glen.hewlett at sympatico.ca> wrote:
>>> 
>>> 
>>> Hi All,
>>> 
>>> Does anyone have some example code for playing audio samples in an assembly program?  I’m making some nice speed improvements in my Pac Man transcode and I thought it would be nice to test with some sound added to the game.  If someone has some code I can take a look at that would be great.
>>> 
>>> Cheers,
>>> Glen
>>> 
>>> -- 
>>> Coco mailing list
>>> Coco at maltedmedia.com
>>> https://pairlist5.pair.net/mailman/listinfo/coco
>>> 
>>> 
>>> 
>>> 
>>> -- 
>>> Coco mailing list
>>> Coco at maltedmedia.com
>>> https://pairlist5.pair.net/mailman/listinfo/coco
>> 
>> 
>> -- 
>> Coco mailing list
>> Coco at maltedmedia.com
>> https://pairlist5.pair.net/mailman/listinfo/coco
> 
> 
> -- 
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco



More information about the Coco mailing list