-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mmml Player as Arduino Sketch #4
Comments
Firstly, thank you very much for trying out the code! There's actually an interesting issue here. On the face of it, it's a simple fix - just add the following at the top of the 'void loop()' function:
The issue is, this will halve the output volume as now the output is just zero for most of the time. You'll also probably hear more audio glitches (it's definitely more 'clicky'). If you remove the Because we have a little more headroom at 16MHz, I've just tried moving the mixing/slowdown code into something like this:
... And it's sounding pretty rough - bright and glassy - like the mixing frequency is audible or something. Theoretically, it should be evenly balanced, so I'm definitely missing something obvious here. The solution might have to clock it properly with a hardware timer but, for now, that first bit of code should be good enough to get it working at 16MHz. I'll leave this issue open and see if I can come up with anything better. |
Thanks for your detailed reply. Congratulations on the software, it's a fascinating piece of work. From what I can tell, it includes:
It's a fantastic piece of software. It'd be great to implement it with timers, as the timing would be easier to resolve, and perhaps the software could do something else in between timer ticks (my interest for embedded devices). I read the article quoted in your piece here: for anyone who hasn't seen it. It's very enlightening. Paul |
By the way, the article does not mention another famous 1-bit implementation, the Apple ][. Much of this work would already have been done by about 1980 by game programmers. |
I'm trying to get my head around the micro-timing in the software. It seems that the period is the time between PORTB= statements in the code where the pulse calculations happen. The location of these statements in your code determines the period between each it seems. Every tick_speed (1024) times through the main loop, you do the music interpretation stuff. This would be a stutter in the output but it seems it's not noticeable. This seems to be PPM, am I right? |
Yeah, I'm an idiot. After I sent that yesterday I realised that there's a much simpler way to get this working nicely without messing with the timing of the mixer. Just change this line: Because we're doubling the frequency, we just need to double the note/tempo values; it doesn't matter at all if the speed of code execution changes, as long as it stays proportionally the same. As an aside, you can also do the mixing nicely on an interrupt:
To answer your other questions (in reverse order):
Also, thank you very much for the kind words! |
Thanks for the mod. I tried it and it works perfectly! The rendition of "till there was you" is hilarious. |
I have written a small MMML file for some tones we use on our products. I was hoping to simulate on a micro, using your mmml player. Here it is:
I don't get any sound at all. Can you spot an error in the file? Thanks, Paul |
Yeah, it's just badly tested code on my part. You need a byte of something in-between the channel declaration commands. It'll compile, but the player will have a meltdown. To fix this, the compiler should just thrown in a hidden byte if a channel is left undeclared/with no data inside. Also, don't forget to put a tempo in! I can't remember if the AVR one has a pre-initialised tempo or not.
You don't HAVE to put a macro in (I think it'll play without), but I don't think I ever tested this without some kind of data declared down there. It's always safer to declare one anyway and stick a byte of whatever in there. |
Any reason why this won;t compile?
|
Oh of course, you just need to add an r4 or whatever to channel D, like this:
You're the first person to really stress-test this, haha. Without a duration command to prompt movement to the next channel's data, the player will hit that |
hey @pdr0663 do you have the code for this mmml player on arduino somewhere? I'd like to try it... |
Yeah I'll try to dig it up.
Paul
*Paul Riley*
Mo: +61 (0)411 781 394
Email: ***@***.***
…On Sat, 28 Oct 2023 at 08:40, farvardin ***@***.***> wrote:
hey @pdr0663 <https://github.com/pdr0663> do you have the code for this
mmml player on arduino somewhere? I'd like to try it...
—
Reply to this email directly, view it on GitHub
<#4 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADECSM2MJD5XXVGCP7P5TPLYBQS5HAVCNFSM5E675AMKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCNZYGM2TIMJXGA3A>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Here it is.
I included the sample mmml file, it's a hoot!
You'll need to check the output pin.
Paul
*Paul Riley*
Mo: +61 (0)411 781 394
Email: ***@***.***
…On Sat, 28 Oct 2023 at 08:40, farvardin ***@***.***> wrote:
hey @pdr0663 <https://github.com/pdr0663> do you have the code for this
mmml player on arduino somewhere? I'd like to try it...
—
Reply to this email directly, view it on GitHub
<#4 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADECSM2MJD5XXVGCP7P5TPLYBQS5HAVCNFSM5E675AMKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCNZYGM2TIMJXGA3A>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Oh, if you don't have access to a compiler, here is the compiler executable
for windows, attached. You'll need to process .mmml files with it, and set
the INCLUDE line in the Arduino code to point to the resulting 'h file.
I've included the resulting file for the demo also, so you can get going
straight away.
Paul
*Paul Riley*
Mo: +61 (0)411 781 394
Email: ***@***.***
On Thu, 2 Nov 2023 at 14:45, Paul Riley ***@***.***> wrote:
Here it is.
I included the sample mmml file, it's a hoot!
You'll need to check the output pin.
Paul
*Paul Riley*
Mo: +61 (0)411 781 394
Email: ***@***.***
On Sat, 28 Oct 2023 at 08:40, farvardin ***@***.***> wrote:
> hey @pdr0663 <https://github.com/pdr0663> do you have the code for this
> mmml player on arduino somewhere? I'd like to try it...
>
> —
> Reply to this email directly, view it on GitHub
> <#4 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ADECSM2MJD5XXVGCP7P5TPLYBQS5HAVCNFSM5E675AMKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCNZYGM2TIMJXGA3A>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
const unsigned char data[802] PROGMEM = {
0x00,0x08,0x01,0x91,0x03,0x18,0x03,0x1F,0xF3,0x32,0xD2,0xF6,0xE2,0x86,0xF6,0xE2,0x86,
0xF6,0xE3,0x86,0xF6,0xE3,0x86,0xF6,0xE3,0x86,0xF6,0xE4,0x86,0xF6,0xE4,0x86,0xF6,0xE4,
0x86,0xF6,0xE4,0x86,0xF6,0xE5,0x86,0xF6,0xE5,0x86,0xF6,0xE5,0x86,0xF6,0xE5,0x86,0xF6,
0xE5,0x86,0xF6,0xE5,0x86,0xF6,0xE5,0x86,0xD4,0xF6,0xE2,0x86,0xF6,0xE2,0x86,0xF6,0xE3,
0x86,0xF6,0xE3,0x86,0xF6,0xE3,0x86,0xF6,0xE4,0x86,0xF6,0xE4,0x86,0xF6,0xE4,0x86,0xF6,
0xE4,0x86,0x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5,0x86,0xF6,0xE5,0x86,0xF6,0xE5,0x86,0xF6,0xE5,0x86,0xF6,0xE5,0x86,0xF6,
0xE5,0x86,0xF6,0xE5,0x86,0xF6,0xE5,0x86,0xF6,0xE5,0x86,0xF6,0xE5,0x86,0xF6,0xE5,0x86,
0xF6,0xE5,0x86,0xF6,0xE5,0x86,0xF6,0xE5,0x86,0xF6,0xE5,0x86,0xF6,0xE5,0x86,0xF6,0xE5,
0x86,0xF6,0xE5,0x86,0xF6,0xE5,0x86,0xF6,0xE5,0x86,0xF6,0xE5,0x86,0xF6,0xE5,0x86,0xF6,
0xE5,0x86,0xF6,0xE5,0x86,0xF6,0xE5,0x86,0x00,0xFF,0x02,0x02,0x02,0x02,0x02,0x00,0xFF,
0x00,0xFF,
};
|
@pdr0663 |
I have implemented the code as an Arduino sketch but I have an issue.
The playback seems to be very fast. I'm using an Arduino Nano, and I believe the clock speed is 16MHz, not 8 MHz. Looking at the timing parts in your code, there is the following:
and
I've tried tweaking these values without success. Can I assume then that the code is inherently tuned to 8MHz clock speed, or is the code easily tunable to a 16MHz clock?
Is there anything inherently problematic using the Arduino bootloader firmware + mmml player sketch?
Paul
The text was updated successfully, but these errors were encountered: