Example #1
0
        protected override void UpdateNote()
        {
            patternDelay = 0;
            for (int ch = 0; ch < module.numberOfChannels; ch++)
            {
                XM_MixerChannel   mc = (XM_MixerChannel)mixChannels[ch];
                XM_PatternChannel pe = (XM_PatternChannel)pattern.patternRows[(int)currentRow].patternChannels[ch];

                mc.effect     = pe.effekt;
                mc.effectArg  = pe.effektOp;
                mc.effectArgX = (mc.effectArg & 0xF0) >> 4;
                mc.effectArgY = (mc.effectArg & 0x0F);

                if (pe.noteIndex == 97)
                {
                    mc.channelVolume = 0.0f;
                }

                if (pe.instrumentIndex > 0 && pe.noteIndex > 0 && pe.noteIndex < 97)
                {
                    mc.instrumentLastIndex = mc.instrumentIndex;
                    mc.instrumentIndex     = pe.instrumentIndex;
                    ResetChannelInstrument(mc);
                    mc.channelVolume   = module.Instruments[(int)mc.instrumentIndex - 1].volume;
                    mc.portamentoStart = (int)mc.period;
                    mc.noteIndex       = (uint)(pe.noteIndex + ((XM_Instrument)module.Instruments[(int)mc.instrumentIndex - 1]).sample.relativeNoteNumber);
                    mc.period          = GetNoteFreq(mc.noteIndex, mc.currentFineTune);
                    mc.portamentoEnd   = (int)mc.period;
                    mc.periodInc       = CalcPeriodIncrement(mc.period);
                }

                if (pe.instrumentIndex > 0 && pe.noteIndex == 0 && pe.instrumentIndex != mc.instrumentLastIndex)
                {
                    mc.instrumentLastIndex = pe.instrumentIndex;
                    mc.instrumentIndex     = pe.instrumentIndex;
                    ResetChannelInstrument(mc);
                    mc.channelVolume = module.Instruments[(int)mc.instrumentIndex - 1].volume;
                }

                if (pe.instrumentIndex > 0 && pe.noteIndex == 0 && pe.instrumentIndex == mc.instrumentLastIndex)
                {
                    mc.channelVolume = module.Instruments[(int)mc.instrumentIndex - 1].volume;
                }

                if (pe.instrumentIndex == 0 && pe.noteIndex > 0 && pe.noteIndex < 97)
                {
                    mc.portamentoStart = (int)mc.period;
                    mc.noteIndex       = (uint)(pe.noteIndex + ((XM_Instrument)module.Instruments[(int)mc.instrumentIndex - 1]).sample.relativeNoteNumber);
                    mc.period          = GetNoteFreq(mc.noteIndex, mc.currentFineTune);
                    mc.portamentoEnd   = (int)mc.period;
                    mc.periodInc       = CalcPeriodIncrement(mc.period);
                    ResetChannelInstrument(mc);
                }
            }

            NextRow();
        }
Example #2
0
        private XM_PatternChannel CreateNewPatternChannel(Stream stream, uint numberOfSamples)
        {
            XM_PatternChannel channel = new XM_PatternChannel();
            byte b0 = ModuleUtils.ReadByte(stream);

            if ((b0 & 0x80) != 0)
            {
                if ((b0 & 0x01) != 0)
                {
                    channel.noteIndex = ModuleUtils.ReadByte(stream);
                }
                if ((b0 & 0x02) != 0)
                {
                    channel.instrumentIndex = ModuleUtils.ReadByte(stream);
                }
                if ((b0 & 0x04) != 0)
                {
                    channel.volumeEffect = ModuleUtils.ReadByte(stream);
                }
                if ((b0 & 0x08) != 0)
                {
                    channel.effekt = ModuleUtils.ReadByte(stream);
                }
                if ((b0 & 0x10) != 0)
                {
                    channel.effektOp = ModuleUtils.ReadByte(stream);
                }
            }
            else
            {
                channel.noteIndex       = (byte)(b0 & 0x7F);
                channel.instrumentIndex = ModuleUtils.ReadByte(stream);
                channel.volumeEffect    = ModuleUtils.ReadByte(stream);
                channel.effekt          = ModuleUtils.ReadByte(stream);
                channel.effektOp        = ModuleUtils.ReadByte(stream);
            }
            if (channel.noteIndex > 0 && channel.noteIndex < 97 && channel.volumeEffect == 0)
            {
                channel.volumeEffect = 0x50;
            }
            return(channel);
        }