paulrosen / abcjs

javascript for rendering abc music notation
Other
1.9k stars 281 forks source link

synth.sequence AudioSequence is not compatible with MidiBuffer.init #929

Open EvanPartidas opened 1 year ago

EvanPartidas commented 1 year ago
let visualObj = renderAbc("*", "CDEC")[0];
let sequence = ABCjs.synth.sequence(visualObj);
let synth = new ABCjs.synth.CreateSynth();
synth.init({ sequence });

Will cause this error self.flattened.tracks is undefined

This (unintuitively) acheives that effect.

let visualObj = renderAbc("*", "CDEC")[0];
let audioTracks = visualObj.setUpAudio();
let synth = new ABCjs.synth.CreateSynth();
synth.init({ sequence: audioTracks });

I'm not sure what the point of synth.sequence is, but it seems MidiBufferOptions.sequence wants an AudioTracks type, not an AudioSequence type.

paulrosen commented 1 year ago

You normally don't need to use sequence. So in the second example you can leave off the last line.

The purpose of that is to override the whole processing stuff if you know exactly what you want. The place that I use it is when the user clicks on a note you can get a callback. Then I create a sequence with just that note in it and play it. If I have anything more complicated I go through the renderAbc() method.