Exemplo n.º 1
0
        public static WaveHeader GetSequencerHeader(Sequencer16 x)
        {
            WaveHeader fileData = new WaveHeader();

            fileData.BitsPerSample = 16;
            fileData.BlockAlign    = ((UInt16)(x.ChannelAmount * 2));
            fileData.NumChannels   = x.ChannelAmount;
            fileData.SampleRate    = x.SampleRate;
            fileData.ByteRate      = ((UInt32)(x.SampleRate * x.ChannelAmount * 2));
            fileData.Subchunk2Size = ((UInt32)(x.Length * x.ChannelAmount * 2));
            fileData.ChunkSize     = 36 + fileData.Subchunk2Size;
            return(fileData);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Loads sequence into binary stream.
        /// </summary>
        /// <param name="x">Sequencer to pick data from.</param>
        /// <param name="target">Target stream.</param>
        public static void WriteSequenceToFile(Sequencer16 x, Stream target)
        {
            WaveHeader   fileData = GetSequencerHeader(x);
            BinaryWriter bw       = new BinaryWriter(target);

            bw.Write(FormBinaryHeader(fileData));
            foreach (Int16[] i in x.Unload())
            {
                foreach (Int16 i_ in i)
                {
                    bw.Write(BitConverter.GetBytes(i_));
                }
            }
        }
Exemplo n.º 3
0
            public SequencerStream(Sequencer16 target)
            {
                foreach (Byte x in WaveFormatter16.FormBinaryHeader(WaveFormatter16.GetSequencerHeader(target)))
                {
                    InternalBuffer.Add(x);
                }

                foreach (Int16[] a in target.Unload())
                {
                    foreach (Int16 b in a)
                    {
                        Byte[] tr = BitConverter.GetBytes(b);
                        InternalBuffer.Add(tr[0]);
                        InternalBuffer.Add(tr[1]);
                    }
                }
            }