MCPcopy Create free account
hub / github.com/HertzDevil/0CC-FamiTracker / InitRecordInstrument

Method InitRecordInstrument

Source/InstrumentRecorder.cpp:302–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

300}
301
302void 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
344void CInstrumentRecorder::FinalizeRecordInstrument()
345{

Callers

nothing calls this directly

Calls 13

IsAPUTriangleFunction · 0.85
GetInstrumentCountMethod · 0.80
GetInstrumentServiceMethod · 0.80
GetSoundChipServiceMethod · 0.80
SetNameMethod · 0.80
SetSettingMethod · 0.80
GetFreeSequenceIndexMethod · 0.80
GetInstrumentManagerMethod · 0.45
MakeMethod · 0.45
GetChannelFullNameMethod · 0.45
getMethod · 0.45
SetSeqEnableMethod · 0.45

Tested by

no test coverage detected