Esempio n. 1
0
        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] : "") + ".vag.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] : "") + ".vag.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;
            }
        }
Esempio n. 2
0
        /// <summary>Reads CSEQ from the file path given.</summary>
        /// <param name="fileName">CSEQ file name.</param>
        /// <param name="textBox1">to be removed</param>
        public bool Read(string fileName, System.Windows.Forms.TextBox textBox1)
        {
            path = Path.GetDirectoryName(fileName);
            name = Path.GetFileNameWithoutExtension(fileName);
            BinaryReaderEx br = BinaryReaderEx.FromFile(fileName);

            header.Read(br);

            if (header.size != br.BaseStream.Length)
            {
                return(false);
            }

            long pos = br.BaseStream.Position;

            for (int i = 0; i < header.longCnt; i++)
            {
                SampleDefReverb sd = new SampleDefReverb();
                sd.Read(br);
                samplesReverb.Add(sd);
            }

            for (int i = 0; i < header.shortCnt; i++)
            {
                SampleDef sd = new SampleDef();
                sd.Read(br);
                samples.Add(sd);
            }

            br.BaseStream.Position = pos;

            //read instruments
            for (int i = 0; i < header.longCnt; i++)
            {
                longSamples.Add(Instrument.GetLong(br));
            }

            for (int i = 0; i < header.shortCnt; i++)
            {
                shortSamples.Add(Instrument.GetShort(br));
            }

            //read offsets
            short[] seqPtrs = br.ReadArrayInt16(header.seqCnt);

            //awesome NTSC demo fix
            int p = (header.seqCnt == 4) ? 1 : 3;

            //checking whether it's 0 or not
            for (int i = 0; i < p; i++)
            {
                if (br.ReadByte() != 0)
                {
                    Log.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 < header.seqCnt; i++)
            {
                br.Jump(seqStart + seqPtrs[i]);

                Sequence seq = new Sequence();
                seq.Read(br, this);

                sequences.Add(seq);
            }

            LoadMetaInstruments(CSEQ.PatchName);

            return(true);
        }