[WIP] 4 channel Music

Probably.
Currently if I have a drum track, I get noise, if I don’t have a drum track I get silence.
I so much want to release this game…

Well, you could use ArduboyPlaytune or ArduboyTones to get your game out the door, and then release a version using ATMlib later when you get it sorted.

nope, can’t get my music to convert nicely. Unless you know of a specific playtune/tones tracker?

Any tracker that can produce a MIDI score can be used with midi2tones to create Playtune or Tones compatible arrays.

I’ve used Rosegarden under Linux.

We found a bug in the editor:

  • addresses are wrong once going over 0xFF (they don’t get split out into 2 bytes)

Also:

  • adding FX in the editor don’t work yet. (they do work in the library)
  • FX repeat song doesn’t work (neither in the library, so even adding manually doesn’t work)

Next week priority:

  • fix address bug
  • make song repeat work
  • start adding FX options in the editor

new update:

  • GOTO advanced FX is working in ATMlib (but not yet in the webplayer)
  • fixed the addresses BUG
  • great progress on the CHANNEL FX EDITOR (adding an FX for the whole channel)

We added a SAVE/LOAD function into the editor. It will save a song.atm file you can reload later on to continue your work :slight_smile:

@spinal :smiley:

2 Likes

I did see that yesterday. However, I says my files are invalid.

@spinal It can’t upload song.h files … those are code (and don’t store the logic of the editor)
It can only load the song.ATM file which is actually json … (which has the logic of the editor)

OH WAIT, you’re right, gonna need to fix that …

cool, I can’t wait for GOTO to be added, I couldn’t figure it out from the source example, so I’ll have to wait.

Couple of questions,

  1. what does the channel field do in the editor?
  2. did you know there’s distortion when multiple notes are played on hardware?, it seems like a volume issue.
  1. by changing the channel field in the track editor, you can play your track on a different channel (different sound) for testing

  2. yes, total volume of all channels together shouldn’t be to high, but for now you can only change that in your song.h file yourself. (once the FX for volume are in the editor, you can lower the volume of each track when needed)

@spinal we fixed the LOAD bug, so now you should be able to load a saved .atm file.

Cool. Forgot all about this, stupid Zelda.

1 Like

We smashed a lot of the SAVE LOAD bugs in the editor. Finally it’s possible to create a tune, save it and load it without the bugs we had before.

Next thing to do:

  • create a manual
  • add song repeat
  • fix the piano roll on windows systems
2 Likes

I started working on a manual for the editor. It’s very basic right now, but it should be enough to get started.

Most important part is, you need to add a VOLUME SET FX to each of the tune channels you’re going to use (not needed for the drum channel) and set it to about 48 (max 64)

http://www.team-arg.org/atmedit-manual.html

PS: yes it’s WIP, so don’t shoot me, but all suggestions are welcome.

1 Like

Hi, I have a question about ATMlib’s PWM mode setup and interrupt handler.

AFAICT ATMlib sets up the maximum timer count frequency, Fast PWM mode and enables the overflow interrupt. The interrupt handler uses a boolean variable toggled on each interrupt to update the timer compare register every two timer overflow cycles.

So I am wondering if “Phase Correct PWM Mode” (section 13.6.4 of the MCU’s datasheet) could be used to achieve the same output waveforms while halving the interrupt rate (and removing the boolean variable toggling). Am I mistaken in my (limited) understanding of AVR PWM modes? Thank you.

1 Like

Hi dxb,

your question is beyond my knowledge of the AVR chip. To be honest the
library is just using the same synth as made by Davey for Squawk :


Our library is just using a different way of interpreting song data, so it
can be much denser.

JO3RI

1 Like

I see, I thought the timer setup and interrupt handler were specific to ATMlib. I’ll try it and see if it works and in case it does work I’ll open a pull request on ATMlib’s GitHub page. Thank you.

1 Like

It seems to work! See https://github.com/TEAMarg/ATMlib/pull/4

I tested most of ATMlib examples and it sounds the same to me. I haven’t hooked up a scope and compared waveforms because I have access to one Arduboy right now (gave the other to my nephews to teach them some programming) and I’d rather not disassemble the only one I have.

This change halves the rate of interrupts being serviced and removes some code from the interrupt handler. Removed code consumed a little less than 10 cycles but at 65kHz that adds up to a seizable amount of cycles. EDIT: removed code took 7 cycles in ‘odd’ interrupts and 21 in ‘even’ ones, plus the 8 cycles of interrupt latency (when not in idle/sleep mode) equals about 36 cycles 31k times per second (~1M cycles per second).

Hi JO3RI,

FYI the code I removed from ATMlib is not in Squawk so maybe someone added it when adapting Squawk for the Arduboy?