Hi everyone,
Please allow me to quickly introduce myself, since this is my first post. I'm utz, chiptune musician and coder. I normally make music and music routines for ZX Spectrum and other machines with 1-bit sound. Never owned a Dragon, but I do like the machine.
Some years ago I stumbled across "Music Maestro" for the Dragon, and immediately took a liking to the sound of the 6-bit DAC. However, Music Maestro is very tedious to use, so I never actually made much with it. But some time ago, I started to think about writing my own sound routine for the Dragon. And in the last days, I finally put that plan into practise.
So, without further ado, here's pcmplay. It's my first piece of 6809 code, so please bear with me Sound is not as clean as I hoped for, but alright for a first attempt, I think.
Anway, the features are as follows:
- 4 channels of PCM WAV playback
- samples have 4-bit depth and are fixed length 256 byte loops
- 16-bit frequency dividers, with a total of 5 octaves
- mixing at a discretion frequency of 7295 Hz
So, it's less powerful than for example CocoTracker, but it also takes less memory. Enough bla bla, here's a demonstration of how it sounds:
https://soundcloud.com/irrlicht-project ... tandy-coco
The source code + demo .bin file can be downloaded at
https://github.com/utz82/pcmplay/archive/master.zip
The code comes with an XM converter for convenient editing of the music. It is however not a general purpose MOD/XM converter, as it only accepts it's own, specially crafted template XM.
Hope you enjoy!
cheers,
-utz
Btw, big thanks to Simon Jonassen for all his help and great advice!
pcmplay - new dragon sound routine
Re: pcmplay - new dragon sound routine
Fantastic ! Love the sound of this tune. I would have no idea how to go about making my own tunes but would be awesome to have some nice music demos that I could run on my real dragon.
Thanks
Thanks
Re: pcmplay - new dragon sound routine
Hi, and welcome to the Archive!
The tune sounds amazing! Does it take too much cpu?
Cheers,
Rob
The tune sounds amazing! Does it take too much cpu?
Cheers,
Rob
Re: pcmplay - new dragon sound routine
Hey Utz....
I'm glad you did this for the DAC !
I really hope that others will indeed find this useful and possibly compose some tunes....
/Simon
I'm glad you did this for the DAC !
I really hope that others will indeed find this useful and possibly compose some tunes....
/Simon
Re: pcmplay - new dragon sound routine
Rob, if it's like the one I did back in the 80's, it's going flat out using the CPU.
To get a 5kHz waveform you need to send a signal to the DAC every 100 microseconds
Looking at the source, his main loop takes 122 clock cycles, so it goes around 7295 times a second, so you get about 3.6kHz max frequency out of it.
I wonder if you could get it better by using DP addressing.
To get a 5kHz waveform you need to send a signal to the DAC every 100 microseconds
Looking at the source, his main loop takes 122 clock cycles, so it goes around 7295 times a second, so you get about 3.6kHz max frequency out of it.
I wonder if you could get it better by using DP addressing.
Re: pcmplay - new dragon sound routine
Thanks everyone
@Rob: Unfortunately, as Paul was guessing, pcmplay hogs the entire CPU time.
@Paul: It would of course be nice to get the loop down to 2 HSYNCs/114 cycles, so one could execute some simple gfx code between DAC updates. The routine however already heavily relies on DP addressing, so I doubt you'll be able to save much time like that. But if anybody finds some extra cycles, please feel free to improve the routine, that's why I open-sourced it
@Rob: Unfortunately, as Paul was guessing, pcmplay hogs the entire CPU time.
@Paul: It would of course be nice to get the loop down to 2 HSYNCs/114 cycles, so one could execute some simple gfx code between DAC updates. The routine however already heavily relies on DP addressing, so I doubt you'll be able to save much time like that. But if anybody finds some extra cycles, please feel free to improve the routine, that's why I open-sourced it
Re: pcmplay - new dragon sound routine
@paul.... this DOES use DP adressing and alot of selfmod too....
122 clocks per inner loop if you take .89 Mhz (890000Hz) and divide that by 122 clocks you get 7295 Hz....
/Simon
122 clocks per inner loop if you take .89 Mhz (890000Hz) and divide that by 122 clocks you get 7295 Hz....
/Simon
Re: pcmplay - new dragon sound routine
(Sorry, I'd missed that it uses DP addressing. I'm fairly sure I had a faster loop than this when I did the same thing back in the 80s, but my code was nothing like this)
The loop goes around 7295 times per second, so the max frequency is 3647Hz - not 7295 Hz.
https://en.wikipedia.org/wiki/Nyquist_rate
(Basically if you have a sine wave at 7295 Hz and sample it at 7295 Hz, you get a flat line, not a wave. If you have a sine wave at 7000 Hz and sample at 7295 Hz, you'll get a lower frequency wave, not a 7000Hz wave. So you need to sample at least twice as fast as the wave frequency to have a chance of getting a wave)
This has a good video (http://www.dsprelated.com/showarticle/733.php). Look at around 9.30 minutes in the video where it shows a 7kHz wave being sampled at 8kHz appearing like a 1kHz wave.
(I did some DSP work at university )
The loop goes around 7295 times per second, so the max frequency is 3647Hz - not 7295 Hz.
https://en.wikipedia.org/wiki/Nyquist_rate
(Basically if you have a sine wave at 7295 Hz and sample it at 7295 Hz, you get a flat line, not a wave. If you have a sine wave at 7000 Hz and sample at 7295 Hz, you'll get a lower frequency wave, not a 7000Hz wave. So you need to sample at least twice as fast as the wave frequency to have a chance of getting a wave)
This has a good video (http://www.dsprelated.com/showarticle/733.php). Look at around 9.30 minutes in the video where it shows a 7kHz wave being sampled at 8kHz appearing like a 1kHz wave.
(I did some DSP work at university )
Re: pcmplay - new dragon sound routine
Hi Utz, what a great way to introduce yourself! I really like what you've done here.
Stew
Re: pcmplay - new dragon sound routine
hey @stew....
told you this was gonna happen earlier this year (if you remember)....
/Simon
told you this was gonna happen earlier this year (if you remember)....
/Simon