/// <summary> /// Initializes a new instance of the SequencePlayer class with the /// specified MIDI sender, tick generator and sequence. /// </summary> /// <param name="midiSender"> /// The MIDI sender to use to send MIDI messages. /// </param> /// <param name="tickGen"> /// The tick generator used for timing the playback of MIDI messages. /// </param> /// <param name="seq"> /// The sequence to playback. /// </param> public SequencePlayer(IMidiSender midiSender, TickGenerator tickGen, Sequence seq) { this.xmidiSender = midiSender; // For each track in the sequence. foreach(Track t in seq) { // Create track player for the track. TrackPlayer player = new TrackPlayer(this.xmidiSender, tickGen, t); trackPlayers.Add(player); // Register to be notified when the track player has reached // the end of the track. player.EndOfTrackReached += new EventHandler(EndOfTrackReachedHandler); } activeTrackCount = trackPlayers.Count; }
/// <summary> /// Initializes a new instance of the SequencePlayer class with the /// specified MIDI sender, tick generator and sequence. /// </summary> /// <param name="midiSender"> /// The MIDI sender to use to send MIDI messages. /// </param> /// <param name="tickGen"> /// The tick generator used for timing the playback of MIDI messages. /// </param> /// <param name="seq"> /// The sequence to playback. /// </param> public SequencePlayer(IMidiSender midiSender, TickGenerator tickGen, Sequence seq) { this.xmidiSender = midiSender; // For each track in the sequence. foreach (Track t in seq) { // Create track player for the track. TrackPlayer player = new TrackPlayer(this.xmidiSender, tickGen, t); trackPlayers.Add(player); // Register to be notified when the track player has reached // the end of the track. player.EndOfTrackReached += new EventHandler(EndOfTrackReachedHandler); } activeTrackCount = trackPlayers.Count; }
public virtual Interactor.Base CreateInteractor(TrackPlayer tp, ChannelMessage cm) { EPointF ptLoc = new EPointF(); int note = cm.Data1; int strength = cm.Data2; int duration = 10; Interactor.Base interactor = null; LocSetter.Base locSetter = null; Endogine.Node node = this._trackSettings[tp.Track.Name]; if (node != null) { if (node["Interactor"]!=null) { string sType = "MusicGame.Midi.Interactor."+node["Interactor"].Text; Type type = Type.GetType(sType); System.Reflection.ConstructorInfo cons = type.GetConstructor(new Type[]{}); interactor = (Interactor.Base)cons.Invoke(new object[]{}); } if (node["LocSetter"]!=null) { string sType = "MusicGame.Midi.LocSetter." + node["LocSetter"].Text; Type type = Type.GetType(sType); System.Reflection.ConstructorInfo cons = type.GetConstructor(new Type[]{}); locSetter = (LocSetter.Base)cons.Invoke(new object[]{}); } } if (interactor==null) interactor = new Interactor.Default(); // if (locSetter==null) // locSetter = new LocSetter.Default(); interactor.Prepare(tp.Track.Name, cm.MidiChannel, this._readAheadMsecs, note, strength, duration, ptLoc); if (locSetter!=null) locSetter.Parent = interactor; this._spritesToStart.Add(interactor); return interactor; }
/// <summary> /// Sets the solo state of a track. /// </summary> /// <param name="index"> /// Index into the sequence of the track to solo. /// </param> /// <param name="solo"> /// A value indicating whether or not to solo the track. /// </param> /// <exception cref="ArgumentOutOfRangeException"> /// Thrown if the track index is out of range. /// </exception> public void SoloTrack(int index, bool solo) { // Enforce preconditions. if (index < 0 || index >= trackPlayers.Count) { throw new ArgumentOutOfRangeException("index", index, "Track index out of range."); } // Get the track player responsible for the track at the specified // index. TrackPlayer player = (TrackPlayer)trackPlayers[index]; // Guard. if (player.Solo == solo) { return; } // Set solo value. player.Solo = solo; // If the track is being soloed. if (solo) { // If no tracks have been soloed so far. if (soloCount == 0) { // For each track player, enable solo mode and turn off all // sounds of those tracks not soloed. foreach (TrackPlayer p in trackPlayers) { p.SoloModeEnabled = true; if (!p.Solo) { p.AllSoundsOff(); } } } // Keep track of the number of tracks soloed. soloCount++; } // Else the track is not being soloed. else { // Keep track of the number of tracks soloed. soloCount--; // If no tracks are soloed, disable the solo mode of each track // player. if (soloCount == 0) { foreach (TrackPlayer p in trackPlayers) { p.SoloModeEnabled = false; } } } }