void GetNewChannelState(const Cell& src, ChannelState& dst, AYM::TrackBuilder& track) { if (const bool* enabled = src.GetEnabled()) { dst.Enabled = *enabled; if (!dst.Enabled) { dst.Sliding = dst.Glissade = 0; dst.SlidingTargetNote = LIMITER; } dst.PosInSample = dst.PosInOrnament = 0; } if (const uint_t* note = src.GetNote()) { assert(src.GetEnabled()); dst.Note = *note; dst.Sliding = dst.Glissade = 0; dst.SlidingTargetNote = LIMITER; } if (const uint_t* sample = src.GetSample()) { dst.SampleNum = *sample; dst.PosInSample = 0; } if (const uint_t* ornament = src.GetOrnament()) { dst.OrnamentNum = *ornament; dst.PosInOrnament = 0; } if (const uint_t* volume = src.GetVolume()) { dst.Volume = *volume; } for (CommandsIterator it = src.GetCommands(); it; ++it) { switch (it->Type) { case ENVELOPE: track.SetEnvelopeType(it->Param1); track.SetEnvelopeTone(it->Param2); dst.Envelope = true; break; case NOENVELOPE: dst.Envelope = false; break; case NOISE_ADD: dst.NoiseAdd = it->Param1; break; case GLISS_NOTE: dst.Sliding = 0; dst.Glissade = it->Param1; dst.SlidingTargetNote = it->Param2; break; case GLISS: dst.Glissade = it->Param1; dst.SlidingTargetNote = LIMITER; break; case NOGLISS: dst.Glissade = 0; break; default: assert(!"Invalid command"); } } }
void GetNewChannelState(const Cell& src, ChannelState& dst, AYM::TrackBuilder& track) { if (const bool* enabled = src.GetEnabled()) { dst.Enabled = *enabled; } dst.VolSlideCounter = 0; dst.SlidingSteps = 0; bool contSample = false, contOrnament = false; bool reloadNote = false; for (CommandsIterator it = src.GetCommands(); it; ++it) { switch (it->Type) { case ENVELOPE: if (-1 != it->Param1) { track.SetEnvelopeType(it->Param1); } if (-1 != it->Param2) { EnvelopeTone = it->Param2; track.SetEnvelopeTone(EnvelopeTone); } break; case ENVELOPE_ON: dst.Envelope = true; break; case ENVELOPE_OFF: dst.Envelope = false; break; case NOISE: dst.BaseNoise = it->Param1; break; case CONT_SAMPLE: contSample = true; break; case CONT_ORNAMENT: contOrnament = true; break; case GLISS: dst.Glissade = it->Param1; dst.SlidingSteps = -1;//infinite sliding break; case SLIDE: { dst.SlidingSteps = it->Param1; const int_t newSliding = (dst.Sliding | 0xf) ^ 0xf; dst.Glissade = -newSliding / (dst.SlidingSteps ? dst.SlidingSteps : 1); dst.Sliding = dst.Glissade * dst.SlidingSteps; break; } case SLIDE_NOTE: { dst.SlidingSteps = it->Param1; dst.SlidingTargetNote = it->Param2; const int_t absoluteSliding = track.GetSlidingDifference(dst.Note, dst.SlidingTargetNote); const int_t newSliding = absoluteSliding - (contSample ? dst.Sliding / 16 : 0); dst.Glissade = 16 * newSliding / (dst.SlidingSteps ? dst.SlidingSteps : 1); reloadNote = true; break; } case AMPLITUDE_SLIDE: dst.VolSlideCounter = dst.VolSlideDelay = it->Param1; dst.VolSlideAddon = it->Param2; break; case BREAK_SAMPLE: dst.BreakSample = true; break; default: assert(!"Invalid cmd"); break; } } if (const uint_t* ornament = src.GetOrnament()) { dst.OrnamentNum = *ornament; } if (const uint_t* sample = src.GetSample()) { dst.SampleNum = *sample; } if (const uint_t* note = src.GetNote()) { dst.Note = *note; reloadNote = true; } if (reloadNote) { dst.CurrentNoise = dst.BaseNoise; if (dst.SlidingSteps <= 0) { dst.Sliding = 0; } if (!contSample) { dst.CurrentSampleNum = dst.SampleNum; dst.PosInSample = 0; dst.VolumeAddon = 0; dst.ToneDeviation = 0; dst.BreakSample = false; } if (!contOrnament) { dst.CurrentOrnamentNum = dst.OrnamentNum; dst.PosInOrnament = 0; dst.NoteAddon = 0; } } if (const uint_t* volume = src.GetVolume()) { dst.Volume = *volume; } }
void GetNewChannelState(const Cell& src, ChannelState& dst, AYM::TrackBuilder& track) { if (const bool* enabled = src.GetEnabled()) { if (*enabled) { dst.SampleIterator.Reset(); } else { dst.SampleIterator.Disable(); } dst.SampleNoiseAccumulator.Reset(); dst.VolumeSlide = 0; dst.NoiseAccumulator.Reset(); dst.NoteAccumulator.Reset(); dst.OrnamentIterator.Reset(); dst.ToneAccumulator.Reset(); dst.EnvelopeAccumulator.Reset(); dst.ToneSlide.Reset(); } if (const uint_t* note = src.GetNote()) { dst.Note = *note + Transposition; } if (const uint_t* sample = src.GetSample()) { dst.SampleIterator.Set(Data->Samples.Get(*sample)); } if (const uint_t* ornament = src.GetOrnament()) { dst.OrnamentIterator.Set(Data->Ornaments.Get(*ornament)); dst.OrnamentIterator.Reset(); dst.NoiseAccumulator.Reset(); dst.NoteAccumulator.Reset(); } if (const uint_t* volume = src.GetVolume()) { dst.Volume = *volume; } for (CommandsIterator it = src.GetCommands(); it; ++it) { switch (it->Type) { case ENVELOPE: track.SetEnvelopeType(it->Param1); dst.Envelope = it->Param2; dst.EnvelopeEnabled = true; break; case ENVELOPE_OFF: dst.EnvelopeEnabled = false; break; case NOISE: dst.Noise = it->Param1; break; case SLIDE: dst.ToneSlide.SetGlissade(it->Param1); break; case SLIDE_NOTE: { const int_t slide = track.GetSlidingDifference(it->Param2, dst.Note); const int_t gliss = slide >= 0 ? -it->Param1 : it->Param1; const int_t direction = slide >= 0 ? -1 : +1; dst.ToneSlide.SetSlide(slide); dst.ToneSlide.SetGlissade(gliss); dst.ToneSlide.SetSlideDirection(direction); dst.Note = it->Param2 + Transposition; } break; } } }