コード例 #1
0
 public BufferedAudioPort(string path, int windowSize = Constants.DEFAULTWINDOWSIZE, int maxBufferSize = Constants.MAXBUFFERSIZE)
 {
     m_WavData  = WavData.Load(path);
     m_Channels = new List <ThroughNode>(m_WavData.channels);
     for (int k = 0; k < m_WavData.channels; k++)
     {
         m_Channels.Add(new ThroughNode());
     }
 }
コード例 #2
0
 public BufferedAudioPort(WavData wav, int windowSize = Constants.DEFAULTWINDOWSIZE, int maxBufferSize = Constants.MAXBUFFERSIZE)
 {
     m_WavData  = wav;
     m_Channels = new List <ThroughNode>(wav.channels);
     for (int k = 0; k < wav.channels; k++)
     {
         m_Channels.Add(new ThroughNode());
     }
 }
コード例 #3
0
 public WaveOutPort(WavData wav, string path, int windowSize = Constants.DEFAULTWINDOWSIZE, int maxBufferSize = Constants.MAXBUFFERSIZE)
 {
     m_WavData  = wav.Copy();
     m_Path     = path;
     m_Channels = new List <ThroughNode>(wav.channels);
     for (int k = 0; k < wav.channels; k++)
     {
         ThroughNode an = new ThroughNode();
         an.OutputRead += An_OutputRead;
         m_Channels.Add(an);
     }
 }
コード例 #4
0
        public static WavData Load(string path)
        {
            WavData w = new WavData();

            using (FileStream fs = new FileStream(path, FileMode.Open))
            {
                using (BinaryReader reader = new BinaryReader(fs))
                {
                    w.chunkID       = reader.ReadInt32();
                    w.fileSize      = reader.ReadInt32();
                    w.riffType      = reader.ReadInt32();
                    w.fmtID         = reader.ReadInt32();
                    w.fmtSize       = reader.ReadInt32();
                    w.fmtCode       = reader.ReadInt16();
                    w.channels      = reader.ReadInt16();
                    w.sampleRate    = reader.ReadInt32();
                    w.fmtAvgBPS     = reader.ReadInt32();
                    w.fmtBlockAlign = reader.ReadInt16();
                    w.bitDepth      = reader.ReadInt16();

                    if (w.fmtSize == 18)
                    {
                        // Read any extra values
                        w.fmtExtraSize = reader.ReadInt16();
                        reader.ReadBytes(w.fmtExtraSize);
                    }

                    w.dataID   = reader.ReadInt32();
                    w.dataSize = reader.ReadInt32();


                    // Store the audio data of the wave file to a byte array.

                    w.data = reader.ReadBytes(w.dataSize);
                }
            }

            return(w);
        }
コード例 #5
0
        public WavData Copy()
        {
            WavData w = new WavData();

            w.chunkID       = this.chunkID;
            w.fileSize      = this.fileSize;
            w.riffType      = this.riffType;
            w.fmtID         = this.fmtID;
            w.fmtSize       = this.fmtSize;
            w.fmtCode       = this.fmtCode;
            w.channels      = this.channels;
            w.sampleRate    = this.sampleRate;
            w.fmtAvgBPS     = this.fmtAvgBPS;
            w.fmtBlockAlign = this.fmtBlockAlign;
            w.bitDepth      = this.bitDepth;
            w.fmtExtraSize  = this.fmtExtraSize;
            w.dataID        = this.dataID;
            w.dataSize      = this.dataSize;
            w.data          = new byte[this.data.Length];
            this.data.CopyTo(w.data, 0);
            return(w);
        }