/// <summary> /// Receives a long midi error message. /// </summary> /// <param name="buffer">The buffer containing the long midi message error.</param> /// <param name="timestamp">Not used. A new timestamp is generated.</param> public override void LongError(MidiBufferStream buffer, long timestamp) { if (NextErrorReceiver != null) { NextErrorReceiver.LongError(buffer, GetCurrentTimestamp()); } }
/// <summary> /// Pushes a long midi message into the queue, marked as error. /// </summary> /// <param name="buffer">A long midi message. Must not be null.</param> /// <param name="timestamp">A time indication of the midi message.</param> public void PushLongError(MidiBufferStream buffer, long timestamp) { MidiPortEvent rec = new MidiPortEvent( MidiPortEventType.LongError, buffer, timestamp); this.Push(rec); }
/// <summary> /// Sends the long midi message to the next sender chain component. /// </summary> /// <param name="buffer">The long midi message.</param> /// <remarks>Long midi messages will reset the running status.</remarks> public void LongData(MidiBufferStream buffer) { Check.IfArgumentNull(buffer, nameof(buffer)); RunningStatus = 0; NextSenderLongData(buffer); }
/// <summary> /// Sends the long midi message to the next sender chain component. /// </summary> /// <param name="buffer">The long midi message.</param> /// <remarks>Long midi messages will reset the running status.</remarks> public void LongData(MidiBufferStream buffer) { Check.IfArgumentNull(buffer, "buffer"); this.RunningStatus = 0; NextSenderLongData(buffer); }
/// <summary> /// Pushes a long midi message into the queue. /// </summary> /// <param name="buffer">A long midi message. Must not be null.</param> /// <param name="timestamp">A time indication of the midi message.</param> public void PushLongData(MidiBufferStream buffer, long timestamp) { MidiPortEvent rec = new MidiPortEvent( MidiPortEventType.LongData, buffer, timestamp); Push(rec); }
public void LongData(MidiBufferStream buffer, long timeIndex) { if (MidiThru) { _outPort.LongData(buffer); } }
/// <summary> /// Constructs a new instance on the <paramref name="stream"/>. /// </summary> /// <param name="stream">Must not be null.</param> public MidiMessageOutStreamWriter(MidiBufferStream stream) { Check.IfArgumentNull(stream, nameof(stream)); BaseStream = stream; StreamWriter = new MidiStreamEventWriter(stream); }
public void LongData(MidiBufferStream buffer, long timestamp) { Trace.WriteLine("Receiving buffer: " + buffer.BytesRecorded); var sysExBuffer = MidiSysExBuffer.From(buffer); ScheduleAddBuffer(sysExBuffer); }
/// <summary> /// Constructs a new instance on the <paramref name="stream"/>. /// </summary> /// <param name="stream">Must not be null.</param> public MidiMessageOutStreamWriter(MidiBufferStream stream) { Contract.Requires(stream != null); Check.IfArgumentNull(stream, "stream"); this.BaseStream = stream; this.StreamWriter = new MidiStreamEventWriter(stream); }
/// <inheritdocs/> public void LongData(MidiBufferStream buffer, long timestamp) { Check.IfArgumentNull(buffer, "buffer"); using (new ScopedStopWatch(LongPerformanceData)) { NextReceiverLongData(buffer, timestamp); } }
/// <summary> /// Call to relay the long midi message data to the next sender component in the chain. /// </summary> /// <param name="buffer">The long midi message data.</param> /// <remarks>The method will fail graciously if the <see cref="Successor"/> property is not set.</remarks> protected void NextSenderLongData(MidiBufferStream buffer) { Check.IfArgumentNull(buffer, nameof(buffer)); if (Successor != null) { Successor.LongData(buffer); } }
/// <summary> /// Call to relay the long midi message data to the next receiver component in the chain. /// </summary> /// <param name="buffer">The long midi message data.</param> /// <param name="timestamp">A time indication of the midi message.</param> /// <remarks>The method will fail graciously if the <see cref="Successor"/> property is not set.</remarks> protected void NextReceiverLongData(MidiBufferStream buffer, long timestamp) { Check.IfArgumentNull(buffer, nameof(buffer)); if (Successor != null) { Successor.LongData(buffer, timestamp); } }
/// <summary> /// Constructs a new instance for a long midi message. /// </summary> /// <param name="recordType">A value appropriate for long midi messages.</param> /// <param name="buffer">The long midi message. Must not be null.</param> /// <param name="deltaTime">A time indication of the midi message.</param> public MidiPortEvent(MidiPortEventType recordType, MidiBufferStream buffer, long deltaTime) { Check.IfArgumentOutOfRange <int>((int)recordType, (int)MidiPortEventType.LongData, (int)MidiPortEventType.LongError, "recordType"); this.RecordType = recordType; this.Data = 0; this.Buffer = buffer; this.Timestamp = deltaTime; }
/// <summary> /// Constructs a new instance for a long midi message. /// </summary> /// <param name="recordType">A value appropriate for long midi messages.</param> /// <param name="buffer">The long midi message. Must not be null.</param> /// <param name="deltaTime">A time indication of the midi message.</param> public MidiPortEvent(MidiPortEventType recordType, MidiBufferStream buffer, long deltaTime) { Check.IfArgumentOutOfRange <int>((int)recordType, (int)MidiPortEventType.LongData, (int)MidiPortEventType.LongError, nameof(recordType)); RecordType = recordType; Data = 0; Buffer = buffer; Timestamp = deltaTime; }
/// <summary> /// Called to prepare <paramref name="buffer"/> for the port. /// </summary> /// <param name="buffer">Must not be null.</param> /// <remarks>Buffers are also marked as streams.</remarks> protected override void OnPrepareBuffer(MidiBufferStream buffer) { Check.IfArgumentNull(buffer, nameof(buffer)); base.OnPrepareBuffer(buffer); // mark buffers as streams buffer.HeaderFlags |= NativeMethods.MHDR_ISSTRM; }
/// <summary> /// Call to relay the long midi message data to the next receiver component in the chain. /// </summary> /// <param name="buffer">The long midi message data.</param> /// <param name="timestamp">A time indication of the midi message.</param> /// <remarks>The method will fail graciously if the <see cref="Successor"/> property is not set.</remarks> protected void NextReceiverLongData(MidiBufferStream buffer, long timestamp) { Contract.Requires(buffer != null); Check.IfArgumentNull(buffer, "buffer"); if (this.Successor != null) { this.Successor.LongData(buffer, timestamp); } }
/// <summary> /// Call to relay the long midi message data to the next sender component in the chain. /// </summary> /// <param name="buffer">The long midi message data.</param> /// <remarks>The method will fail graciously if the <see cref="Successor"/> property is not set.</remarks> protected void NextSenderLongData(MidiBufferStream buffer) { Contract.Requires(buffer != null); Check.IfArgumentNull(buffer, "buffer"); if (this.Successor != null) { this.Successor.LongData(buffer); } }
public static MidiSysExBuffer From(MidiBufferStream buffer) { int length = (int)buffer.BytesRecorded; var sysExBuffer = new MidiSysExBuffer(length); buffer.Position = 0; buffer.Read(sysExBuffer._buffer, 0, length); return(sysExBuffer); }
/// <summary> /// Constructs a new instance on the specified <paramref name="stream"/>. /// </summary> /// <param name="stream">A stream provided by a <see cref="MidiOutStreamPort"/>. Must not be null.</param> public MidiStreamEventWriter(MidiBufferStream stream) { Check.IfArgumentNull(stream, "stream"); if (!stream.CanWrite) { throw new ArgumentException( Properties.Resources.MidiStreamWriter_StreamNotWritable, "stream"); } BaseStream = stream; InnerWriter = new BinaryWriter(stream); }
public MidiStreamEventWriter(MidiBufferStream stream) { Contract.Requires(stream != null); Contract.Requires(stream.CanRead); Check.IfArgumentNull(stream, "stream"); if (!stream.CanWrite) { throw new ArgumentException( Properties.Resources.MidiStreamWriter_StreamNotWritable, "stream"); } this.BaseStream = stream; this.InnerWriter = new BinaryWriter(stream); }
/// <summary> /// Puts a long midi error in the queue. /// </summary> /// <param name="buffer">Error buffer. Must not be null.</param> /// <param name="timestamp">A time indication of the midi message.</param> public override void LongError(MidiBufferStream buffer, long timestamp) { Check.IfArgumentNull(buffer, "buffer"); this.queue.PushLongError(buffer, timestamp); }
public void LongData(MidiBufferStream buffer, long timestamp) { //not implemented }
/// <summary> /// Passes the long midi message to the next receiver component. No filtering is applied. /// </summary> /// <param name="buffer">The long midi message data.</param> /// <param name="timestamp">A time indication of the midi message.</param> public void LongData(MidiBufferStream buffer, long timestamp) { Check.IfArgumentNull(buffer, "buffer"); NextReceiverLongData(buffer, timestamp); }
public void LongError(MidiBufferStream buffer, long timestamp) { _appData.ReceiveErrorCount++; }
/// <inheritdocs/> public abstract void LongError(MidiBufferStream buffer, long timestamp);
/// <summary> /// Puts a long midi error in the queue. /// </summary> /// <param name="buffer">Error buffer. Must not be null.</param> /// <param name="timestamp">A time indication of the midi message.</param> public override void LongError(MidiBufferStream buffer, long timestamp) { Check.IfArgumentNull(buffer, nameof(buffer)); _queue.PushLongError(buffer, timestamp); }
private static MidiOutPortBase ProcessStreaming(int outPortId, MidiFileData fileData, IEnumerable <MidiFileEvent> notes, MidiOutPortCaps caps) { var outPort = new MidiOutStreamPort(); outPort.Open(outPortId); outPort.BufferManager.Initialize(10, 1024); outPort.TimeDivision = fileData.Header.TimeDivision; // TODO: extract Tempo from meta messages from the file. // 120 bpm (uSec/QuarterNote). outPort.Tempo = 500000; Console.WriteLine(String.Format("Midi Out Stream Port '{0}' is now open.", caps.Name)); MidiMessageOutStreamWriter writer = null; MidiBufferStream buffer = null; MidiFileEvent lastNote = null; foreach (var note in notes) { if (writer == null) { // brute force buffer aqcuirement. // when callbacks are implemented this will be more elegant. do { buffer = outPort.BufferManager.RetrieveBuffer(); if (buffer != null) { break; } Thread.Sleep(50); } while (buffer == null); writer = new MidiMessageOutStreamWriter(buffer); } if (writer.CanWrite(note.Message)) { if (lastNote != null) { // fixup delta time artifically... writer.Write(note.Message, (int)(note.AbsoluteTime - lastNote.AbsoluteTime)); } else { writer.Write(note.Message, (int)note.DeltaTime); } } else { outPort.LongData(buffer); writer = null; Console.WriteLine("Buffer sent..."); if (!outPort.HasStatus(MidiPortStatus.Started)) { outPort.Restart(); } } lastNote = note; } return(outPort); }
public void LongData(MidiBufferStream buffer, long timestamp) { }
public void LongData(MidiBufferStream buffer, long timestamp) { // we're not doing sys-ex. }