and synth objects can be used as instruments for tracks...
but track:addNote only supports MIDI notes?
I see this in both the Lua and C APIs and was curious to know why this is the case?
I'm asking because I'm trying to replicate arbitrary 80's coin-op music which was often a series of notes that didn't directly correspond to the musical scale that MIDI uses.
For example, this is fine:
local synth = snd.synth.new(snd.kWaveSine)
synth:playNote(1800, 0.5, 1)
Originally, playdate.sound.synth just had a playNote() function that took a frequency argument. At some point I also wanted to be able to use MIDI note numbers so I added playMIDINote() as an alternative, since the code can't tell from context whether the number you give it is a frequency or a note and I couldn't reuse the same function like I did when I added support there for note names (A4 etc.). Anyway, the important thing here is that the MIDI note doesn't have to be a whole number: 60.5 is halfway between C3 and C#3.
When I implemented track:addNote() I didn't think to call it addMIDINote instead, and I probably should have for consistency. If you give it a number in the second argument it's interpreted as a MIDI note instead of a frequency. To convert frequency to MIDI note (in the C3 middle C standard) you can use
function freqToNote(f)
return 39.863137 * math.log(f) - 36.376317
end