Beispiel #1
0
        public XmSynthesizer(MusicXm aMusicXm)
        {
            musicXm   = aMusicXm;
            noteArray = new XmNote[aMusicXm.GetNumberOfChannels()];

            for (int i = 0; i < aMusicXm.GetNumberOfChannels(); i++)
            {
                noteArray[i] = new XmNote();
            }
        }
Beispiel #2
0
        public void Update(float[] aData, int aChannels, int aSampleRate)
        {
            frame++;

            if (index != frame / tempo)
            {
                index = frame / tempo;

                if (index < musicXm.GetPatternChunkArray()[patternNumber].GetNumberOfRowsInPattern())
                {
                    for (int i = 0; i < musicXm.GetNumberOfChannels(); i++)
                    {
                        if (musicXm.note[i][patternNumber][index] != 0)
                        {
                            InstrumentChunk lInstrumentChunk = musicXm.GetInstrumentChunkArray()[( int )musicXm.instrument[i][patternNumber][index] - 1];
                            synthesizer.NoteOn(i, ( int )musicXm.note[i][patternNumber][index], lInstrumentChunk);
                        }
                        else
                        {
                            synthesizer.FadeOut(i);
                            synthesizer.IncrementEnvelope(i);
                        }
                    }
                }
                else
                {
                    frame = 0;
                    patternIndex++;
                    patternNumber = musicXm.GetPatternOrderTable()[patternIndex];

                    Logger.LogNormal("■Pattern:" + patternNumber.ToString());

                    if (patternIndex >= musicXm.GetSongLength())
                    {
                        patternIndex = musicXm.GetRestartPosition();

                        Logger.LogNormal("■Loop.");
                    }
                }
            }

            synthesizer.SynthesizeWaveform(aData, aChannels, aSampleRate);
        }