Using:
hardware 1.13.1 (affected)
Mac OS simulator 1.13.1 (NOT affected)
Tried this using both a WaveSynth and SampleSynth. Both affected.
Creating a sequence from a midi and creating instruments works fine before playing the sequence.
Now, while the sequence is playing, I might want to change the instrument for a track. This also works fine as long as no note is playing for that track.
If there is a note playing, however there is a high chance of a crash on device, with the error
SoundSource 0x<address> doesn't have a lua wrapper
I have isolated this to the setInstrument call; creation of the instrument in itself does not cause the crash.
When removing the sequence:play() call, the crash does not occur immediately, but the track goes silent. It might then crash when the sequence:play() call is invoked at a later time.
Sample code:
function EditorViewModel:getTrack(trackNum)
return self.sequence:getTrackAtIndex(trackNum)
end
function masterplayer.newWaveSynth(trackProps)
local s = snd.synth.new(trackProps.instrument.id or snd.kWaveSawtooth)
s:setVolume(trackProps.volume or defaultWaveVolume)
s:setADSR(
trackProps.attack or defaultWaveAttack,
trackProps.decay or defaultWaveDecay,
trackProps.sustain or defaultWaveSustain,
trackProps.release or defaultWaveRelease
)
return s
end
local inst = snd.instrument.new()
for _= 1, polyphony do
inst:addVoice(masterplayer.newWaveSynth(trackProps))
end
local track = self:getTrack(trackNum)
track:setInstrument(inst) -- when commenting this line, crash does not occur
--while the sequence is already playing, calling :play() notifies it of the changes
self.sequence:play()