示例#1
0
        private static void UpdateNotes(int channel)
        {
            if (SongPlayer.ChannelNotes[channel] == 0 && Notes[channel] != 0)
            {
                if (Drums[channel] == 0)
                {
                    Midi.NoteOff(channel, Notes[channel] + NoteOffsets[channel] + SongPlayer.ChannelTranspose[channel], 0);
                }
                else
                {
                    Midi.NoteOff(9, Drums[channel], 0);
                }

                Notes[channel] = SongPlayer.ChannelNotes[channel];
            }

            if (SongPlayer.ChannelNoteStart[channel])
            {
                if (SongPlayer.ChannelNotes[channel] != 0)
                {
                    if (SongPlayer.ChannelPortamento[channel] != Portamento[channel])
                    {
                        Midi.ControlChange(channel, Midi.Controls.PortamentoEnable, SongPlayer.ChannelPortamento[channel] == 0 ? 0 : 127);
                        Portamento[channel] = SongPlayer.ChannelPortamento[channel];
                    }

                    if (Notes[channel] != 0)
                    {
                        Midi.NoteOff(channel, Notes[channel] + NoteOffsets[channel] + SongPlayer.ChannelTranspose[channel], 0);
                    }

                    if (SongPlayer.ChannelNotes[channel] != 0)
                    {
                        //Midi.NoteOn(channel, SongPlayer.ChannelNotes[channel] + NoteOffsets[channel] + SongPlayer.ChannelTranspose[channel], (int)((SongPlayer.ChannelVelocities[channel] / 15.0f) * 127.0f));
                        Midi.NoteOn(channel, SongPlayer.ChannelNotes[channel] + NoteOffsets[channel] + SongPlayer.ChannelTranspose[channel], (int)(((SongPlayer.ChannelVelocities[channel] + 1) / 64.0f) * 127.0f));
                    }
                    //Midi.NoteOn(channel, SongPlayer.ChannelNotes[channel] + NoteOffsets[channel] + SongPlayer.ChannelTranspose[channel], 127);
                }
                else
                {
                    //if (Notes[channel] != 0)
                    //	Midi.NoteOff(9, Drums[channel], 0);

                    var note = SongPlayer.ChannelInstruments[channel] == 0 ?
                               36 :
                               38;

                    //Midi.NoteOn(9, 38, (int)((SongPlayer.ChannelVelocities[channel] / 15.0f) * 127.0f));
                    Midi.NoteOn(9, note, (int)(((SongPlayer.ChannelVelocities[channel] + 1) / 64.0f) * 127.0f));
                    //Midi.NoteOn(9, 38, 127);

                    Midi.NoteOff(9, note, 0);
                }

                Notes[channel] = SongPlayer.ChannelNotes[channel];
            }
        }
示例#2
0
        private static void UpdateNotes(int channel)
        {
            if (SongPlayer.ChannelNotes[channel] == 0 && Notes[channel] != 0)
            {
                if (Drums[channel] == 0)
                {
                    Midi.NoteOff(channel, Notes[channel] + NoteOffsets[channel] + Transpose[channel], 0);
                }
                else
                {
                    Midi.NoteOff(9, Drums[channel], 0);
                }

                Notes[channel] = SongPlayer.ChannelNotes[channel];
            }
            else if (SongPlayer.ChannelNoteStart[channel])
            {
                if (Drums[channel] == 0)
                {
                    if (Notes[channel] != 0)
                    {
                        Midi.NoteOff(channel, Notes[channel] + NoteOffsets[channel] + Transpose[channel], 0);
                    }

                    if (SongPlayer.ChannelNotes[channel] != 0)
                    {
                        Midi.NoteOn(channel, SongPlayer.ChannelNotes[channel] + NoteOffsets[channel] + Transpose[channel], (int)((SongPlayer.ChannelVelocities[channel] / 15.0f) * 127.0f));
                    }
                    //Midi.NoteOn(channel, SongPlayer.ChannelNotes[channel] + NoteOffsets[channel] + Transpose[channel], 32);
                }
                else
                {
                    if (Notes[channel] != 0)
                    {
                        Midi.NoteOff(9, Drums[channel], 0);
                    }

                    if (SongPlayer.ChannelNotes[channel] != 0)
                    {
                        Midi.NoteOn(9, Drums[channel], (int)((SongPlayer.ChannelVelocities[channel] / 15.0f) * 127.0f));
                    }
                    //Midi.NoteOn(9, Drums[channel], 127);

                    //Midi.NoteOff(9, Drums[channel], 0);
                }

                Notes[channel] = SongPlayer.ChannelNotes[channel];
            }
        }
示例#3
0
        private static void UpdateTranspose(int channel)
        {
            if (Transpose[channel] != SongPlayer.ChannelTranspose[channel])
            {
                if (Notes[channel] != 0)
                {
                    if (Drums[channel] == 0)
                    {
                        Midi.NoteOff(channel, Notes[channel] + NoteOffsets[channel] + Transpose[channel], 0);

                        Midi.NoteOn(channel, Notes[channel] + NoteOffsets[channel] + SongPlayer.ChannelTranspose[channel], (int)((SongPlayer.ChannelVelocities[channel] / 15.0f) * 127.0f));
                    }
                }

                Transpose[channel] = SongPlayer.ChannelTranspose[channel];
            }
        }
示例#4
0
        private static void UpdateInstruments(int channel)
        {
            if (Instruments[channel] != SongPlayer.ChannelInstruments[channel])
            {
                if (Notes[channel] != 0)
                {
                    Midi.NoteOff(channel, Notes[channel] + NoteOffsets[channel], 0);
                }

                var instrument = 80;
                var offset     = 12;

                switch (SongPlayer.ChannelInstruments[channel])
                {
                case 0x06:
                    //instrument = 121;
                    instrument = 122;
                    offset     = 0;
                    break;

                case 0x10:
                    instrument = 29;
                    break;

                case 0x11:
                    instrument = 38;
                    //instrument = 80;
                    //instrument = 36;
                    //instrument = 87;
                    break;

                case 0x12:
                    instrument = 18;
                    //instrument = 20;
                    //instrument = 82;
                    break;

                case 0x13:
                    //instrument = 83;
                    //instrument = 50;
                    instrument = 48;
                    offset     = 24;
                    break;

                case 0x14:
                    instrument = 112;
                    offset     = 36;
                    break;

                case 0x15:
                    //instrument = 38;
                    instrument = 29;
                    offset     = 12;
                    break;

                case 0x1A:
                    //instrument = 30;
                    instrument = 29;
                    offset     = 12;
                    break;

                case 0x1B:
                    instrument = 38;
                    //instrument = 39;
                    offset = 24;
                    break;

                case 0x1D:
                    instrument = 49;
                    //instrument = 39;
                    offset = 24;
                    break;

                case 0x36:
                    //instrument = 56;
                    instrument = 61;
                    //instrument = 63;
                    //instrument = 51;
                    offset = 24;
                    break;

                case 0x3A:
                    if (Song == 0x03)
                    {
                        instrument = 114;
                        offset     = 36;
                    }
                    else if (Song == 0x0B)
                    {
                        instrument = 56;
                        offset     = 12;
                    }
                    else
                    {
                        instrument = 82;
                        offset     = 36;
                    }
                    break;

                case 0x3B:
                    if (Song == 0x05)
                    {
                        instrument = 56;
                        offset     = 24;
                    }
                    else if (Song == 0x0B)
                    {
                        //instrument = 56;
                        //instrument = 57;
                        instrument = 61;
                        //instrument = 58;
                        offset = 24;
                    }
                    else
                    {
                        instrument = 104;
                        //instrument = 106;
                        //instrument = 105;
                        //instrument = 84;
                        //instrument = 82;
                        //instrument = 83;
                        offset = 36;
                    }
                    break;

                case 0x3C:
                    instrument = 56;
                    offset     = 24;
                    break;

                case 0x3E:
                    instrument = 38;
                    offset     = 24;
                    break;
                }

                Midi.ProgramChange(channel, instrument);

                Instruments[channel] = SongPlayer.ChannelInstruments[channel];
                NoteOffsets[channel] = offset;
            }
        }
示例#5
0
        private static void UpdateInstruments(int channel)
        {
            if (Instruments[channel] != SongPlayer.ChannelInstruments[channel])
            {
                if (Notes[channel] != 0)
                {
                    if (Drums[channel] != 0)
                    {
                        Midi.NoteOff(9, Drums[channel], 0);
                    }
                    else
                    {
                        Midi.NoteOff(channel, Notes[channel] + NoteOffsets[channel] + Transpose[channel], 0);
                    }

                    Notes[channel] = 0;
                }

                var instrument = -1;
                var offset     = 0;
                Drums[channel] = 0;

                switch (SongPlayer.ChannelInstruments[channel])
                {
                case 0x00:
                    Drums[channel] = Midi.Drums.BassDrum;
                    break;

                case 0x01:
                    Drums[channel] = Midi.Drums.SnareDrum;
                    break;

                case 0x02:
                    Drums[channel] = Midi.Drums.HiHat;
                    break;

                case 0x13:
                    Drums[channel] = Midi.Drums.HandClap;
                    break;

                case 0x03:
                    instrument = Midi.Patches.PickBass;
                    offset     = 12;
                    break;

                case 0x04:
                    //instrument = 50;
                    //instrument = 81;
                    instrument = 86;
                    offset     = 36;
                    break;

                case 0x05:
                    instrument = 48;
                    offset     = 36;
                    break;

                case 0x06:
                    instrument = 80;
                    offset     = 36;
                    break;

                case 0x07:
                    //instrument = 30;
                    instrument = 29;
                    //instrument = 86;
                    offset = 9;
                    break;

                case 0x08:
                    instrument = 0;
                    offset     = 24;
                    break;

                case 0x09:
                    instrument = 80;
                    offset     = 36;
                    break;

                case 0x0A:
                    instrument = 83;
                    offset     = 24;
                    break;

                case 0x0B:
                    instrument = 127;
                    offset     = 0;
                    break;

                case 0x0E:
                    //instrument = 87;
                    instrument = 84;
                    offset     = 12;
                    break;

                default:
                    Debug.WriteLine("Unknown Instrument: " + SongPlayer.ChannelInstruments[channel].ToString("X2"));
                    instrument = 80;
                    offset     = 12;
                    break;
                }

                if (instrument != -1)
                {
                    Midi.ProgramChange(channel, instrument);
                }

                Instruments[channel] = SongPlayer.ChannelInstruments[channel];
                NoteOffsets[channel] = offset;
            }
        }