예제 #1
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="_data">音声データ配列</param>
 public MusicData(MusicUnit[] _data)
 {
     this.data = new MusicUnit[_data.Length];
     for (int i = 0; i < _data.Length; i++) this.data[i] = _data[i];
     return;
 }
예제 #2
0
        /// <summary>
        /// 指定ポイント数の音声データを読み込む。
        /// <para>モノラルなら、Left/Rightどちらにも格納される。</para>
        /// </summary>
        /// <param name="size">データサイズ[point]</param>
        /// <returns>ファイルを完読すると、0を書き込んで返す</returns>
        private MusicUnit[] ReadFile(int size)
        {
            MusicUnit[] music = new MusicUnit[size];  // これにデータを格納して返す

            if (this.isOpenStatus) {
                for (int i = 0; i < size && this.ReadWaveDataSize < this.fileInfo.WaveDataSize; i++){
                    if (this.ReadWaveDataSize < this.fileInfo.WaveDataSize)
                    {
                        // まず左を埋める
                        if (this.fileInfo.ResolutionBit == 8) music[i].Left = (int)this.reader.ReadSByte();
                        if (this.fileInfo.ResolutionBit == 16) music[i].Left = (int)this.reader.ReadInt16();
                        if (this.fileInfo.ResolutionBit == 24) music[i].Left = this.ReadInt24 (this.reader);
                        if (this.fileInfo.ResolutionBit == 32) music[i].Left = (int)this.reader.ReadInt32();
                        // 次に、ステレオ音源なら右を埋める
                        switch (this.fileInfo.Channel)
                        {
                            case Channel.Stereo:
                                if (this.fileInfo.ResolutionBit == 8) music[i].Right = (int)this.reader.ReadSByte();
                                if (this.fileInfo.ResolutionBit == 16) music[i].Right = (int)this.reader.ReadInt16();
                                if (this.fileInfo.ResolutionBit == 24) music[i].Right = this.ReadInt24(this.reader);
                                if (this.fileInfo.ResolutionBit == 32) music[i].Right = (int)this.reader.ReadInt32();
                                break;
                            case Channel.Monoral:
                                music[i].Right = music[i].Left;
                                break;
                        }
                        this.ReadWaveDataSize += (UInt32)this.fileInfo.BlockSize;   // 読み込んだデータ量を更新
                    }
                    else {
                        music[i].Left = 0;                                          // 読めるデータが無くなると、0を書き込んで返す
                        music[i].Right = 0;
                    }
                }
            }
            return music;
        }