| 1329 | } |
| 1330 | |
| 1331 | void BambooTracker::funcJamKeyOn(JamKey key, int keyNum, const TrackAttribute& attrib, bool volumeSet, |
| 1332 | std::shared_ptr<AbstractInstrument> inst) |
| 1333 | { |
| 1334 | if (playback_->isPlayingStep()) playback_->stopPlaySong(); // Reset |
| 1335 | |
| 1336 | if (attrib.source == SoundSource::RHYTHM) { |
| 1337 | if (volumeSet) |
| 1338 | opnaCtrl_->setVolumeRhythm(attrib.channelInSource, std::min(curVolume_, bt_defs::NSTEP_RHYTHM_VOLUME - 1)); |
| 1339 | opnaCtrl_->setKeyOnFlagRhythm(attrib.channelInSource); |
| 1340 | opnaCtrl_->updateKeyOnOffStatusRhythm(true); |
| 1341 | } |
| 1342 | else { |
| 1343 | std::vector<JamKeyInfo>&& list = jamMan_->keyOn(key, attrib.channelInSource, attrib.source, keyNum); |
| 1344 | if (list.size() == 2) { // Key off |
| 1345 | JamKeyInfo& offInfo = list[1]; |
| 1346 | switch (offInfo.source) { |
| 1347 | case SoundSource::FM: |
| 1348 | if (songStyle_.type == SongType::FM3chExpanded && offInfo.channelInSource == 2) { |
| 1349 | opnaCtrl_->keyOffFM(2, true); |
| 1350 | opnaCtrl_->keyOffFM(6, true); |
| 1351 | opnaCtrl_->keyOffFM(7, true); |
| 1352 | opnaCtrl_->keyOffFM(8, true); |
| 1353 | } |
| 1354 | else { |
| 1355 | opnaCtrl_->keyOffFM(offInfo.channelInSource, true); |
| 1356 | } |
| 1357 | break; |
| 1358 | case SoundSource::SSG: |
| 1359 | opnaCtrl_->keyOffSSG(offInfo.channelInSource, true); |
| 1360 | break; |
| 1361 | case SoundSource::ADPCM: |
| 1362 | opnaCtrl_->keyOffADPCM(true); |
| 1363 | break; |
| 1364 | default: |
| 1365 | break; |
| 1366 | } |
| 1367 | } |
| 1368 | |
| 1369 | if (!inst) { // Use current instrument if not specified |
| 1370 | inst = instMan_->getInstrumentSharedPtr(curInstNum_); |
| 1371 | } |
| 1372 | JamKeyInfo& onInfo = list.front(); |
| 1373 | |
| 1374 | Note&& note = jam_utils::makeNote(onInfo, curOctave_); |
| 1375 | |
| 1376 | switch (onInfo.source) { |
| 1377 | case SoundSource::FM: |
| 1378 | if (auto fm = std::dynamic_pointer_cast<InstrumentFM>(inst)) |
| 1379 | opnaCtrl_->setInstrumentFM(onInfo.channelInSource, fm); |
| 1380 | if (volumeSet) { |
| 1381 | int vol; |
| 1382 | if (volFMReversed_) vol = effect_utils::reverseFmVolume(curVolume_, true); |
| 1383 | else vol = std::min(curVolume_, bt_defs::NSTEP_FM_VOLUME - 1); |
| 1384 | opnaCtrl_->setVolumeFM(onInfo.channelInSource, vol); |
| 1385 | } |
| 1386 | if (songStyle_.type == SongType::FM3chExpanded && onInfo.channelInSource == 2) { |
| 1387 | opnaCtrl_->keyOnFM(2, note, true); |
| 1388 | opnaCtrl_->keyOnFM(6, note, true); |
nothing calls this directly
no test coverage detected