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

Method ImportCellText

Source/TextExporter.cpp:306–405  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

304 }
305
306 stChanNote ImportCellText(unsigned fxMax, stChannelID chan) { // // //
307 stChanNote Cell; // // //
308
309 CStringA sNote = ReadToken();
310 if (sNote == "...") { Cell.Note = note_t::none; }
311 else if (sNote == "---") { Cell.Note = note_t::halt; }
312 else if (sNote == "===") { Cell.Note = note_t::release; }
313 else {
314 if (sNote.GetLength() != 3)
315 throw MakeError("note column should be 3 characters wide, '%s' found.", (LPCSTR)sNote);
316
317 if (IsAPUNoise(chan)) { // // // noise
318 int h = ImportHex(sNote.Left(1)); // // //
319 Cell.Note = ft0cc::doc::pitch_from_midi(h);
320 Cell.Octave = ft0cc::doc::oct_from_midi(h);
321
322 // importer is very tolerant about the second and third characters
323 // in a noise note, they can be anything
324 }
325 else if (sNote.GetAt(0) == '^' && sNote.GetAt(1) == '-') { // // //
326 unsigned o = sNote.GetAt(2) - '0';
327 if (o >= ECHO_BUFFER_LENGTH)
328 throw MakeError("out-of-bound echo buffer accessed.");
329 Cell.Note = note_t::echo;
330 Cell.Octave = o;
331 }
332 else {
333 int n = 1;
334 switch (sNote.GetAt(0)) {
335 case 'c': case 'C': n = value_cast(note_t::C); break;
336 case 'd': case 'D': n = value_cast(note_t::D); break;
337 case 'e': case 'E': n = value_cast(note_t::E); break;
338 case 'f': case 'F': n = value_cast(note_t::F); break;
339 case 'g': case 'G': n = value_cast(note_t::G); break;
340 case 'a': case 'A': n = value_cast(note_t::A); break;
341 case 'b': case 'B': n = value_cast(note_t::B); break;
342 default:
343 throw MakeError("unrecognized note '%s'.", (LPCSTR)sNote);
344 }
345 switch (sNote.GetAt(1)) {
346 case '-': case '.': break;
347 case '#': case '+': ++n; break;
348 case 'b': case 'f': --n; break;
349 default:
350 throw MakeError("unrecognized note '%s'.", (LPCSTR)sNote);
351 }
352 while (n < value_cast(note_t::C)) n += NOTE_RANGE;
353 while (n > value_cast(note_t::B)) n -= NOTE_RANGE;
354 Cell.Note = enum_cast<note_t>(n);
355
356 int o = sNote.GetAt(2) - '0';
357 if (o < 0 || o >= OCTAVE_RANGE) {
358 throw MakeError("unrecognized octave '%s'.", (LPCSTR)sNote);
359 }
360 Cell.Octave = o;
361 }
362 }
363

Callers 1

ImportFileMethod · 0.80

Calls 8

IsAPUNoiseFunction · 0.85
pitch_from_midiFunction · 0.85
oct_from_midiFunction · 0.85
value_castFunction · 0.85
sizeFunction · 0.85
GetSoundChipServiceMethod · 0.80
GetLengthMethod · 0.45
TranslateEffectNameMethod · 0.45

Tested by

no test coverage detected