Hi,
I'm trying to play a midi file where the notes are created from one .wav audio sample.
I have something working, but on the device, some audio glitches are audible (They are hardly noticable in the simulator).
I'm not sure if it is a bug or if I'm doing something wrong, but it seems that this problem appeared recently (or it is just that I never noticed it in the simulator).
Here is attached a sample code (and an attached project file).
local snd = playdate.sound
local music = snd.sequence.new("sounds/music.mid")
local sample = snd.sample.new("sounds/note")
local ntracks = music:getTrackCount()
for i=1,ntracks do
local track = music:getTrackAtIndex(i)
local instrument = snd.instrument.new()
for i=1,track:getPolyphony() do
instrument:addVoice(snd.synth.new(sample))
end
track:setInstrument(instrument)
end
music:play()
function playdate.update()
end
I also do goToStep in my app (not in this sample code).
And the audio glitch is so weird !
It looks like the audio data is coming from some internal audio waveform.
This was a regression that popped up in 1.12.1, causing sample-based synths to play past the end of the sample data. I've fixed that, and also a separate issue with goToStep() sometimes going to the step before the requested step, if you've noticed anything odd there.
We're working our way through the 1.13 MR queue now, hope to have a beta out soon and a release not too much later!
I should have mentioned a simple workaround: Switching to a mono sample avoids the overrun bug. I was also going to say you could use getSubsample() to make a new sample from the data that's half the length, so that when it plays twice as long it actually ends at the right spot, but there's another bug (fixed for 1.13) where sample synths can't play subsamples.