| 300 | } |
| 301 | |
| 302 | void CInstrumentRecorder::InitRecordInstrument() |
| 303 | { |
| 304 | if (m_pModule->GetInstrumentManager()->GetInstrumentCount() >= MAX_INSTRUMENTS) { |
| 305 | m_iDumpCount = 0; m_iRecordChannel = { }; return; |
| 306 | } |
| 307 | inst_type_t Type = [&] { // optimize this |
| 308 | switch (m_iRecordChannel.Chip) { |
| 309 | case sound_chip_t::APU: case sound_chip_t::MMC5: return INST_2A03; |
| 310 | case sound_chip_t::VRC6: return INST_VRC6; |
| 311 | // case sound_chip_t::VRC7: return INST_VRC7; |
| 312 | case sound_chip_t::FDS: return INST_FDS; |
| 313 | case sound_chip_t::N163: return INST_N163; |
| 314 | case sound_chip_t::S5B: return INST_S5B; |
| 315 | } |
| 316 | return INST_NONE; |
| 317 | }(); |
| 318 | *m_pDumpInstrument = FTEnv.GetInstrumentService()->Make(Type); // // // |
| 319 | if (!*m_pDumpInstrument) return; |
| 320 | |
| 321 | auto str = std::string {FTEnv.GetSoundChipService()->GetChannelFullName(m_iRecordChannel)}; |
| 322 | (*m_pDumpInstrument)->SetName(u8"from " + str); |
| 323 | |
| 324 | if (Type == INST_FDS) { |
| 325 | m_pSequenceCache[sequence_t::Arpeggio]->SetSetting(SETTING_ARP_FIXED); |
| 326 | return; |
| 327 | } |
| 328 | if (auto Inst = dynamic_cast<CSeqInstrument *>(m_pDumpInstrument->get())) { |
| 329 | for (auto i : enum_values<sequence_t>()) { |
| 330 | Inst->SetSeqEnable(i, 1); |
| 331 | Inst->SetSeqIndex(i, m_pModule->GetInstrumentManager()->GetFreeSequenceIndex(Type, i, nullptr)); |
| 332 | } |
| 333 | m_pSequenceCache[sequence_t::Arpeggio]->SetSetting(SETTING_ARP_FIXED); |
| 334 | // m_pSequenceCache[sequence_t::Pitch]->SetSetting(SETTING_PITCH_ABSOLUTE); |
| 335 | // m_pSequenceCache[sequence_t::HiPitch]->SetSetting(SETTING_PITCH_ABSOLUTE); |
| 336 | // VRC6 sawtooth 64-step volume |
| 337 | if (IsAPUTriangle(m_iRecordChannel)) |
| 338 | Inst->SetSeqEnable(sequence_t::DutyCycle, 0); |
| 339 | } |
| 340 | m_iRecordWaveSize = 32; // DEFAULT_WAVE_SIZE |
| 341 | m_iRecordWaveCount = 0; |
| 342 | } |
| 343 | |
| 344 | void CInstrumentRecorder::FinalizeRecordInstrument() |
| 345 | { |
nothing calls this directly
no test coverage detected