Beispiel #1
0
 public void Encode(Stream source, string outputPath, SongTags tags, byte[] reusedBuffer)
 {
     using (var reader = new WaveFileReader(source))
     {
         MediaFoundationEncoder.EncodeToAac(
             reader,
             outputPath
             );
     }
 }
        public void Encode(Stream source, string outputPath, SongTags tags, byte[] reusedBuffer)
        {
            //If WaveFileWriter supported writing tags/metadata, we would need to decode and encode
            //the streams properly, rather than just copying the data across.
            //Unfortunately, it doesn't support tags.

            using (var destStream = File.OpenWrite(outputPath))
            {
                source.CopyTo(destStream);
            }
        }
 public void Encode(Stream source, string outputPath, SongTags tags, byte[] reusedBuffer)
 {
     using (var reader = new WaveFileReader(source))
         using (var writer = new AiffFileWriter(outputPath, reader.WaveFormat))
         {
             while (reader.Position < reader.Length)
             {
                 int bytesRead = reader.Read(reusedBuffer, 0, reusedBuffer.Length);
                 writer.Write(reusedBuffer, 0, bytesRead);
             }
         }
 }
        public void Encode(Stream source, string outputPath, SongTags tags, byte[] reusedBuffer)
        {
            WaveFileReader    reader = null;
            LameMP3FileWriter writer = null;

            try             //Idk if using captures the original instance - clearer to just use try-finally
            {
                reader = new WaveFileReader(source);

                var id3 = new ID3TagData()
                {
                    Artist = tags.Artist,
                    Title  = tags.Title,
                };

                if (LamePreset != null)
                {
                    writer = new LameMP3FileWriter(outputPath, reader.WaveFormat, LamePreset.GetValueOrDefault(), id3);
                }
                else if (BitRate != null)
                {
                    writer = new LameMP3FileWriter(outputPath, reader.WaveFormat, BitRate.GetValueOrDefault(), id3);
                }
                else
                {
                    writer = new LameMP3FileWriter(outputPath, reader.WaveFormat, LAMEPreset.STANDARD, id3);
                }

                while (reader.Position < reader.Length)
                {
                    int bytesRead = reader.Read(reusedBuffer, 0, reusedBuffer.Length);
                    writer.Write(reusedBuffer, 0, bytesRead);
                }
            }
            finally
            {
                reader?.Dispose();
                writer?.Dispose();
            }
        }
Beispiel #5
0
 public void Encode(Stream source, string outputPath, SongTags tags, byte[] reusedBuffer)
 {
 }