public bool Read(BinaryReaderEx br) { long pos = br.BaseStream.Position; int size = br.ReadInt32(); byte longCnt = br.ReadByte(); byte shortCnt = br.ReadByte(); short seqCnt = br.ReadInt16(); for (int i = 0; i < longCnt; i++) { samplesReverb.Add(SampleDefReverb.FromReader(br)); } for (int i = 0; i < shortCnt; i++) { samples.Add(SampleDef.FromReader(br)); } //read offsets short[] seqPtrs = br.ReadArrayInt16(seqCnt); //awesome NTSC demo fix int p = (seqCnt == 4) ? 1 : 3; //checking whether it's 0 or not for (int i = 0; i < p; i++) { if (br.ReadByte() != 0) { Console.WriteLine("unknown 3 bytes block - not null at " + br.HexPos()); } } //saving sequence data offset int seqStart = (int)br.BaseStream.Position; //loop through all sequences for (int i = 0; i < seqCnt; i++) { br.Jump(seqStart + seqPtrs[i]); sequences.Add(Sequence.FromReader(br)); } LoadMetaInstruments(CSEQ.PatchName); if (br.BaseStream.Position - pos != size) { Helpers.Panic(this, PanicType.Warning, "CSEQ size mismatch!"); } return(true); }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { AudioFileReader wave = null; WaveOut outputSound = null; string x = ""; if (treeView1.SelectedNode.Parent != null) { if (treeView1.SelectedNode.Parent.Index == 1) { SampleDef sd = seq.samples[treeView1.SelectedNode.Index]; propertyGrid1.SelectedObject = sd; x = seq.path + "\\" + seq.name + "\\" + sd.Tag + (Howl.sampledict.ContainsKey(sd.SampleID) ? "_" + Howl.sampledict[sd.SampleID] : "") + ".wav"; } if (treeView1.SelectedNode.Parent.Index == 0) { SampleDefReverb sd = seq.samplesReverb[treeView1.SelectedNode.Index]; propertyGrid1.SelectedObject = sd; x = seq.path + "\\" + seq.name + "\\" + sd.Tag + (Howl.sampledict.ContainsKey(sd.SampleID) ? "_" + Howl.sampledict[sd.SampleID] : "") + ".wav"; } if (File.Exists(x)) { try { wave = new NAudio.Wave.AudioFileReader(x); outputSound = new WaveOut(); outputSound.Init(wave); outputSound.Play(); } catch (Exception ex) { textBox1.Text = ex.Message; } } } else { propertyGrid1.SelectedObject = null; } }