![]() ![]() There are two other overloads of the Mp3Writer constructor: one that accepts a BE_CONFIG instance, which is a structure translated from LAME that describes how the stream must be compressed (bit rate, compression method, quality, etc.). The input stream is read until the end and all the data is written to the writer, which converts it to MP3 format and saves the result to the output stream. The Mp3Writer constructor is called passing as the first parameter the stream where to write the resulting MP3 stream (in this case, a FileStream), and as second parameter the WaveFormat that specifies the format of the input data. While ( (read = InStr.Read(buff, 0, buff.Length)) > 0 )įirst, a WaveStream is created to read the uncompressed audio data from a WAV file, then a Mp3Writer is created. Mp3Writer writer = new Mp3Writer( new FileStream( " SomeFile.mp3",īyte buff = new byte WaveStream InStr = new WaveStream( " SomeFile.wav") The following code shows the simplest way to use the MP3 compressor with the default configuration: Within this library, I included all the translation of structures, constants, and functions needed to use lame_enc.dll. All other classes related to the MP3 compressor are in a library yeti.mp3. Using the codeĪudioWriter and other base and tools classes are in a library named yeti.mmedia. AudioWriter receives audio data in PCM format, then the data is compressed and written to the resulting stream, or just written without modifications using a specific format (WAV format, for instance, as in the WaveWriter class). The compressor I describe in this article ( Mp3Writer) is a class derived from AudioWriter, which is a binary writer that can be used as a base of writers for different audio streams (different audio formatters, compressors, etc.). One problem to mention about the use of the DLL is that in the current version, it is not possible to compress two streams at the same time. ![]() This DLL exports a few functions and it is relatively easy to use. However, an easier way to achieve that goal is to use the LAME compressor through the functions exposed by the lame_enc.dll. While it is true that the LAME encoder is written in C and all source code is available, one could think of compiling these source files in managed C++ to obtain a managed compressor. In this work, there is code from the article: A low level audio player in C# by Ianier Munoz. See this website for technical and copyright information regarding the LAME project. The solution was to use the LAME MP3 encoder, specifically to wrap in C# the functions of lame_enc.dll. NET framework and I couldn't find the exact solution, so I decided to write one. Then I looked for some MP3 compressor done for. ![]() The first question to my previous article ( C Sharp Ripper) was about how to rip directly to MP3 format. Download source code and demo project - 160 Kb.You can always convert lossless audio to a lossy format, but you can't convert lossy audio back into higher-quality lossless formats. Lossless formats also allow you to future-proof your audio, should you ever acquire better equipment for listening. That said, if storage space isn't an issue and you have high-quality speakers or headphones, a lossless format might be the way to go. As long as you don't set the bitrate too low, it's unlikely you'll be able to tell much difference between lossless and lossy audio, especially if you're listening on your phone through earbuds. Lossy formats are fine in most situations. This reduces the overall sound quality, but also makes it a much smaller file and therefore easier on your hard drive. Lossy formats use a lower bitrate, stripping out a good portion of an audio file's data.Lossless formats have all the original data intact and are therefore much bigger files.The first step to reducing the size of audio files is to recognize whether your audio is "lossless" or "lossy". Should You Choose Lossless or Lossy Audio Compression? ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |