Exemplo n.º 1
0
 private void HandleChannelMessagePlayed(object sender, ChannelMessageEventArgs e)
 {
     if (ConfigManager.GetProperty(PropertyItem.NoteConversionMode) != "1")
     {
         if (ConfigManager.GetBooleanProperty(PropertyItem.SoundEffects) && !disposed)
         {
             outDevice.Send(mordhauOutDevice.FilterNote(trackSelectionManager.FilterMidiEvent(e.Message, e.TrackId)));
         }
         else
         {
             mordhauOutDevice.SendNote(trackSelectionManager.FilterMidiEvent(e.Message, e.TrackId));
         }
     }
     else
     {
         outDevice.Send(trackSelectionManager.FilterMidiEvent(e.Message, e.TrackId));
     }
 }
Exemplo n.º 2
0
 private void HandleChannelMessagePlayed(object sender, ChannelMessageEventArgs e)
 {
     if (ConfigManager.GetProperty(PropertyItem.NoteConversionMode) != "1")
     {
         if (ConfigManager.GetBooleanProperty(PropertyItem.SoundEffects) && !disposed)
         {
             try
             {
                 outDevice.Send(mordhauOutDevice.FilterNote(trackSelectionManager.FilterMidiEvent(e.Message, e.TrackId)));
             }
             catch (Exception) { }
             // You can edit the track while it's playing and the edits will take place live in Mordhau as it's playing.
             // Though you probably shouldn't do this, but it's better than just erroring out.
         }
         else
         {
             mordhauOutDevice.SendNote(trackSelectionManager.FilterMidiEvent(e.Message, e.TrackId));
         }
     }
     else
     {
         outDevice.Send(trackSelectionManager.FilterMidiEvent(e.Message, e.TrackId));
     }
 }
Exemplo n.º 3
0
        private void HandleChannelMessagePlayed(object sender, ChannelMessageEventArgs e)
        {
            if (ConfigManager.GetProperty(PropertyItem.NoteConversionMode) != "1")
            {
                if (ConfigManager.GetBooleanProperty(PropertyItem.SoundEffects) && !disposed)
                {
                    var filtered = trackSelectionManager.FilterMidiEvent(e.Message, e.TrackId);
                    //if (e.Message.Data2 > 0) // Avoid spamming server with 0 velocity notes
                    //{

                    //Melanchall.DryWetMidi.Core.NoteEvent nEvent;
                    // I don't know how to do this without Melanchall package but it's gonna be a bitch to convert the event types here...


                    //midiOut.SendEvent(new Melanchall.DryWetMidi.Core.NoteOnEvent((Melanchall.DryWetMidi.Common.SevenBitNumber)filtered.Data1, (Melanchall.DryWetMidi.Common.SevenBitNumber)filtered.Data2));
                    // Below: Sound to match, then unfiltered sound.  Or leave commented for no sound.
                    if (outDevice != null && !outDevice.IsDisposed) // If they change song prefs while playing, this can fail, so just skip then
                    {
                        try
                        {
                            if (ConfigManager.GetIntegerProperty(PropertyItem.Instrument) == 9)
                            {
                                // Drums...
                                // Ignore any notes that aren't on glockenspiel
                                if (filtered.MidiChannel == 9) // glocken
                                {
                                    // Figure out where it ranks on DrumNoteCounts
                                    //int drumNote = 0;
                                    //for(int i = 0; i < DrumNoteCounts.Count(); i++)
                                    //{
                                    //    if(DrumNoteCounts[i].Key == filtered.Data1)
                                    //    {
                                    //        drumNote = i;
                                    //        break;
                                    //    }
                                    //}
                                    // Assume it's no longer 0 for now...
                                    // Now just map it to a dictionary of most popular notes on drums
                                    if (DrumMappings.MidiToRustMap.ContainsKey(filtered.Data1))
                                    {
                                        var newNote = new ChannelMessage(filtered.Command, filtered.MidiChannel, DrumMappings.MidiToRustMap[filtered.Data1], filtered.Data2);
                                        outDevice.Send(newNote);
                                        return;
                                    }
                                }
                            }
                            else
                            {
                                var note = rustOutDevice.FilterNote(filtered, trackSelectionManager.NoteOffset +
                                                                    (trackSelectionManager.MidiChannels.ContainsKey(e.Message.MidiChannel) ? trackSelectionManager.MidiChannels[e.Message.MidiChannel].offset : 0));
                                if (note != null)
                                {
                                    outDevice.Send(note);
                                }
                            }
                        }
                        catch (Exception) { } // Ignore exceptions, again, they might edit things while it's trying to play
                    }
                    //}
                    //outDevice.Send(filtered);
                }
                else
                {
                    mordhauOutDevice.SendNote(trackSelectionManager.FilterMidiEvent(e.Message, e.TrackId), trackSelectionManager.NoteOffset +
                                              (trackSelectionManager.MidiChannels.ContainsKey(e.Message.MidiChannel) ? trackSelectionManager.MidiChannels[e.Message.MidiChannel].offset : 0));
                }
            }
            else
            {
                if (outDevice != null)
                {
                    outDevice.Send(trackSelectionManager.FilterMidiEvent(e.Message, e.TrackId));
                }
            }
        }