init method
Future<void>
init(
- String mainPath, {
- String accentedPath = '',
- int bpm = 120,
- int volume = 50,
- bool enableTickCallback = false,
- int timeSignature = 4,
- int sampleRate = 44100,
override
Implementation
@override
Future<void> init(
String mainPath, {
String accentedPath = '',
int bpm = 120,
int volume = 50,
bool enableTickCallback = false,
int timeSignature = 4,
int sampleRate = 44100,
}) async {
_sampleRate = sampleRate;
_audioContext = web.AudioContext(
web.AudioContextOptions(
latencyHint: 'interactive'.toJS, sampleRate: _sampleRate.toDouble()),
);
_mainSoundBuffer = await _bytesToAudioBuffer(mainPath);
if (mainPath == '') {
throw 'mainPath is empty';
}
if (accentedPath == '') {
_accentedSoundBuffer = _mainSoundBuffer;
} else {
_accentedSoundBuffer = await _bytesToAudioBuffer(accentedPath);
}
_bpm = bpm;
_timeSignature = timeSignature;
_volume = volume / 100;
_enableTickCallback = enableTickCallback;
}