Topic: QChan on Arduino

This time I decided to give QChan a go. This is another kind of engine from the previous two, one that uses actual variable pulse width. So that's a new thing to try. I learned about a trick that allows to generate one-shot pulses using the Fast PWM mode on AVR in advance, but turned out that it is simply not needed, as naive approach with just delayMicroseconds works very well.

I added an enhanced mode just for fun. Original QChan's loop runs at 8663 Hz. Turns out that Arduino has no problem to run it at 86630 Hz, with code written all in C! This improves the sound quality quite a bit.

Again, the clicky drums aren't 100% recreated, just an approximation of the sound is implemented, because they were using ever-changing sample rate, and that's does not fit the simple timer interrupt-driven design well.

Again, you can just compile QChan modules in Beepola in order to play them with this port.


The music in the test is MovieMovies1's 'cant think of a music either'.

By the way, if someone don't know, Beepola is capable to extract music back from tap files that were generated with it. This may come handy when you need to get music for testing and need to recompile it to a different address or something. See File>Import.

Post's attachments

arduino_qchan.zip 12.29 kb, 35 downloads since 2017-02-15 

You don't have the permssions to download the attachments of this post.
website - 1bit music - other music - youtube - bandcamp - patreon (latest news there)

Re: QChan on Arduino

thanks a lot, again, that's very impressive. I'd say the sound is perfectly recreated on the arduino. On some tunes I know by heart, I can't tell the difference from the original.
For the enhanced version, it sounds sometimes out of tune, in comparison to the normal mode (I've added in attachement a tune which shows this).

Post's attachments

music_data_vapeurs.h 6.31 kb, 12 downloads since 2017-02-15 

You don't have the permssions to download the attachments of this post.

Re: QChan on Arduino

Guess 10x sample rate is just too much for the 16-bit adders. Can be tweaked, if neccessary. For example, 5x sample rate:

#define SAMPLE_RATE           (3500000/80)
#define MUSIC_FRAME           64*5
#define DRUM_DOWNSAMPLE      5

website - 1bit music - other music - youtube - bandcamp - patreon (latest news there)

4 (edited by utz 2017-02-15 10:12:13)

Re: QChan on Arduino

Wow Shiru, looks like you're on a roll!

Since Arduino 1-bit seems all the rage now, I thought I'd give the avra+avrdude combo a try. Works like a charm, successfully produced a beep in asm!

Indeed, 16 MHz is a lot, especially considering the instructions are also super-fast. Guess I'll have to get used to writing purposefully slow asm code. Or just write complex enough routines, heh. Well, for now I'll leave things at "yay, my toolchain works" but next time I get bored with my other projects I might actually go and try writing a dedicated routine for this thing.

Edit: Wow, I just found out that ATmega has a fixed-length, 2-cycle MULtiply instruction. This should make it possible to implement stuff like 1-bit Phase distortion, perhaps even FM.

Re: QChan on Arduino

I think with 5x it's a good compromise, it sounds better than 10x in my opinion.

Re: QChan on Arduino

hey Shiru, now people on chipmusic.org want an arduino synth out of this: http://chipmusic.org/forums/topic/19450 … n-arduino/ wink

Re: QChan on Arduino

utz, yeah, I believe a lot of very impressive 1-bit stuff can be pulled of a bare AVR programmed in assembly. Really worth to give it a shot eventually.

garvalf, well, a MIDI controlled synth it totally doable, but it is much more work compared to these simple players, the sound synthesis part of the code would be just a small part of it. I'm thinking about it time to time, but have no plans to do it in anytime soon. It is difficult enough already to find time to invest into these smaller projects.

website - 1bit music - other music - youtube - bandcamp - patreon (latest news there)

Re: QChan on Arduino

yeah, I can guess that. I hope with the wonders of open source, there will be someone else interested in coding this kind of thing!
I've already redirected people to your 1bit studio vst plugin!