//reads CSEQ from given binaryreader public bool Read(BinaryReaderEx br, CSEQ cs) { //read header if (!header.Read(br)) { return(false); } //read offsets short[] seqOffsets = br.ReadArrayInt16(header.trackNum); //padding i guess? if (header.trackNum % 2 == 0) { br.ReadInt16(); } //save current position to read tracks int trackData = (int)br.BaseStream.Position; //loop through all tracks for (int i = 0; i < header.trackNum; i++) { //jump to track offset br.Jump(trackData + seqOffsets[i]); //read track CTrack t = new CTrack(); t.Read(br, i); //add track to the list tracks.Add(t); } return(true); }
public List <MidiEvent> ToMidiEvent(int absTime, int channel, CSEQ seq, CTrack ct) { List <MidiEvent> events = new List <MidiEvent>(); //TrackPatch tp = new TrackPatch(); absTime += wait; //we can't go beyond 16 with midi channel = (channel <= 16) ? channel : 16; if (CSEQ.IgnoreVolume) { velocity = 127; } var p = pitch; if (CSEQ.PatchMidi) { if (ct.isDrumTrack) { if (evt == CSEQEvent.NoteOn || evt == CSEQEvent.NoteOff) { p = (byte)seq.shortSamples[pitch].info.Key; } } else { if (evt == CSEQEvent.ChangePatch) { CSEQ.ActiveInstrument = pitch; p = (byte)seq.longSamples[CSEQ.ActiveInstrument].info.Midi; } else if (evt == CSEQEvent.NoteOn || evt == CSEQEvent.NoteOff) { try { p += (byte)seq.longSamples[CSEQ.ActiveInstrument].info.Pitch; } catch //(Exception ex) { } } } } switch (evt) { case CSEQEvent.NoteOn: events.Add(new NoteEvent(absTime, channel, MidiCommandCode.NoteOn, p, velocity)); break; case CSEQEvent.NoteOff: events.Add(new NoteEvent(absTime, channel, MidiCommandCode.NoteOff, p, velocity)); break; case CSEQEvent.ChangePatch: // events.Add(new ControlChangeEvent(absTime, channel, MidiController.MainVolume, seq.longSamples[pitch].velocity / 2)); events.Add(new PatchChangeEvent(absTime, channel, p)); break; case CSEQEvent.BendAssume: events.Add(new PitchWheelChangeEvent(absTime, channel, p * 64)); break; case CSEQEvent.PanAssume: events.Add(new ControlChangeEvent(absTime, channel, MidiController.Pan, p / 2)); break; case CSEQEvent.VelAssume: events.Add(new ControlChangeEvent(absTime, channel, MidiController.MainVolume, p / 2)); break; //not really used //case CSEQEvent.EndTrack2: case CSEQEvent.EndTrack: events.Add(new MetaEvent(MetaEventType.EndTrack, 0, absTime)); break; } return(events); }
public int GetLongSampleIDByTrack(CTrack ct) { return(longSamples[ct.instrument].sampleID); }