Bitrate Can Help You Get Better Quality in MP3 and MP4


Free Download Mp4Gain
picture

Bitrate Can Help You Get Better Quality in MP3 and MP4

Bitrate Can Help You Get Better Quality in MP3 and MP4

Let’s Talk About Bitrate in MP3 and MP4

Bitrate can make or break the quality of your music or video files. I’ve spent years working with audio and video, and I can tell you that bitrate is a game-changer when it comes to getting the best sound and picture quality. Imagine a water pipe: the bitrate is like the pipe’s width. A wider pipe (higher bitrate) lets more water (data) flow through, giving you a richer sound or clearer video. Lower bitrate, on the other hand, restricts the data flow, which is like squeezing a pipe down; the result is less quality. Let’s dive into how bitrate impacts MP3 and MP4 quality and why understanding this can transform your listening and viewing experience.

What is Bitrate and Why Does It Matter?

Bitrate is the rate at which data is processed and transferred. In MP3s and MP4s, bitrate affects quality more than you might think. Higher bitrate means better quality, but also larger file sizes. Think of it like digital storage in your closet: high-bitrate files store every detail, but they take up more space. Lower bitrate compresses the details, which saves space but sacrifices some quality.

How Bitrate Affects MP3 Quality

For MP3 audio, bitrate is crucial. High-bitrate MP3s preserve more of the original recording’s sound detail, making music sound full and dynamic. I remember testing low-bitrate MP3s on different sound systems, and each time, they sounded flat and lifeless. If you want rich bass and clear vocals, go for a higher bitrate.

Common MP3 Bitrates

  • 128 kbps – Standard quality, good for most casual listeners.
  • 192 kbps – Enhanced clarity, offering decent audio for music enthusiasts.
  • 256 kbps – Higher quality with noticeable improvements in bass and vocals.
  • 320 kbps – Top-notch quality, closest to the original recording without being lossless.

How Bitrate Affects MP4 Quality

With MP4 video files, bitrate impacts both the video and audio components. When I watch a movie in high-bitrate MP4, the colors are vivid, and the sounds are rich. A low-bitrate MP4 might show pixelation and murky audio, especially on larger screens. This is why bitrate matters for video just as much as audio.

Recommended MP4 Bitrates

  • 500-1000 kbps – Suitable for low-resolution video, good for small screens.
  • 1000-2500 kbps – Ideal for standard definition video.
  • 2500-5000 kbps – Recommended for HD quality, providing clearer visuals.
  • 5000+ kbps – Best for Full HD and higher, excellent clarity on large screens.

Choosing the Right Bitrate: Balancing Quality and File Size

When selecting bitrate, it’s essential to balance quality with file size. You don’t always need the highest bitrate—sometimes, it’s more about fitting your needs. For instance, if you’re streaming on a mobile device, a lower bitrate can still provide good quality while saving data. However, if you’re playing files on high-end speakers, go for the highest bitrate possible.

Bitrate and Streaming: What You Should Know

When streaming MP3 or MP4 files, bitrate influences both quality and buffering speed. Higher bitrate streams may deliver better quality but can cause more buffering if your internet speed isn’t up to par. Personally, I recommend adjusting bitrate based on your internet connection to avoid interruptions.

How to Check and Adjust Bitrate

Checking bitrate is straightforward. On most devices, you can view the bitrate information within the file properties. Adjusting bitrate usually requires re-encoding with software that allows you to choose the bitrate. It’s like resizing a photo; changing bitrate affects file quality and size, so choose the right balance based on your needs.

Is Higher Always Better? When to Opt for Lower Bitrate

While high bitrate typically means better quality, there are cases where lower bitrate works just fine. For podcasts or spoken-word audio, for instance, a lower bitrate still delivers good clarity without taking up much space. It’s all about the type of content and how you’re consuming it.

Comparing Bitrate to Sample Rate and Resolution

Though bitrate is vital, sample rate and resolution also play roles in quality. For MP3s, sample rate affects audio fidelity, and for MP4s, resolution impacts video clarity. Together, these factors determine overall quality. I find that focusing on bitrate alone can sometimes mislead; balancing all three aspects yields the best results.

Practical Tips for Optimal Bitrate Selection

To optimize bitrate, consider both your device and personal preferences. For everyday music listening on headphones, 192 kbps MP3 might be enough. But for home theater setups, I suggest 320 kbps or lossless formats. Adjusting based on usage can save storage and still offer great sound.

Latest Words on Bitrate and Quality

Bitrate is a powerful factor in determining the quality of MP3 and MP4 files. Whether you’re listening to music or watching videos, selecting the right bitrate makes a difference. With the right tools, like Mp4Gain, you can achieve the perfect balance between quality and file size for any format or device.

Comments:

Wow, this article really explained bitrate well! I always thought higher was better but now I see it’s not that simple. Good job!

I wish there was more info on sample rates. I think that impacts quality too, right?

My friend shared this with me, and I have to say, it’s been super helpful. I feel like I finally get what bitrate is!

This article cleared up so much for me. I was struggling to understand why my audio files were so big, now I get it. Thanks!

Could you go into detail about bitrate in streaming? I think that’s a big topic too!

I’m not a tech person, but this really helped me understand why my audio files sound different at different bitrates. Nice work!

My son is a musician, and I shared this with him to help with his recordings. He said it’s super helpful, thank you!

I was looking for info on MP4 bitrate specifically, and this nailed it! I’m a video editor, so quality is everything to me.

Love the real-life examples in this! Makes something technical feel easy to understand. Keep up the great work!

I’m kinda new to this and was overwhelmed with all the info about bitrate. This is really straightforward. Appreciate it!

Thanks for explaining bitrate so clearly. I always had a hard time choosing settings, but now I know exactly what to do.

Just what I was looking for! Really needed a simple explanation of bitrate and this article delivered. Thanks!

Can you add a section on bitrate comparison? Like a chart or something. It’d be useful for quick reference!

This article was so informative! I’d been looking for something like this that’s easy to understand. Cheers!

I work in audio production, and I shared this with my team. Great explanations, especially for beginners. Thank you!

https://x.com/ricardo_mx_news/status/1850664808464474479


Free Download Mp4Gain
picture


Mp4Gain Main Window
picture


Mp4Gain Features
picture


Free Download Mp4Gain
picture

MP3 Bitrate Calculation Methods

MP3 Bitrate Calculation Methods

MP3 Bitrate
MP3 Bitrate
MP3 Bitrate
MP3 Bitrate

What is MP3 Bitrate?

MP3 bitrate is the amount of data that is used to encode an MP3 audio file. The higher the bitrate, the higher the quality of the audio file. However, higher bitrates also result in larger file sizes.

How is MP3 Bitrate Calculated?

MP3 bitrate is calculated using a variety of factors, including the complexity of the audio signal, the desired quality of the audio file, and the target file size.

What are the Different Types of MP3 Bitrate Calculation Methods?

There are two main types of MP3 bitrate calculation methods:

  • Constant bitrate (CBR): This method uses a constant bitrate for the entire audio file. This results in a consistent audio quality throughout the file, but it can also result in larger file sizes for complex audio signals.
  • Variable bitrate (VBR): This method uses a variable bitrate, which means that the bitrate changes depending on the complexity of the audio signal. This results in smaller file sizes for complex audio signals, but it can also result in a slight variation in audio quality.

Which MP3 Bitrate Calculation Method is Best?

The best MP3 bitrate calculation method depends on your needs. If you need a consistent audio quality throughout the file, then CBR is the best option. If you are more concerned about file size, then VBR is the best option.

How to Choose the Right MP3 Bitrate for Your Needs

When choosing the right MP3 bitrate for your needs, you should consider the following factors:

  • The type of audio signal: Complex audio signals, such as those that contain a lot of high-frequency content, require a higher bitrate than simple audio signals.
  • The desired quality of the audio file: If you want the highest possible quality, then you should use a higher bitrate. If you are more concerned about file size, then you can use a lower bitrate.
  • The target file size: If you have a specific file size in mind, then you can use a bitrate calculator to determine the bitrate that you need.

Conclusion

MP3 bitrate is an important factor to consider when encoding audio files. By understanding the different types of MP3 bitrate calculation methods and how to choose the right bitrate for your needs, you can ensure that your audio files sound great and have a reasonable file size.

Here are some additional details about the different types of MP3 bitrate calculation methods:

  • Constant bitrate (CBR): This method is the simplest to understand and implement. It is also the most reliable, as it ensures that the audio quality is consistent throughout the file. However, it can result in larger file sizes for complex audio signals.
  • Variable bitrate (VBR): This method is more complex than CBR, but it can result in smaller file sizes for complex audio signals. This is because VBR allows the encoder to use a lower bitrate for less complex parts of the audio signal, and a higher bitrate for more complex parts of the audio signal. However, VBR can result in a slight variation in audio quality, depending on the complexity of the audio signal.

Ultimately, the best MP3 bitrate calculation method for you depends on your specific needs. If you need a consistent audio quality throughout the file, then CBR is the best option. If you are more concerned about file size, then VBR is the best option.

What’s behind the MP3 Audio Format?

What’s behind the MP3 Audio Format?

MP3 Audio Format
MP3 Audio Format

When most people hear the word MP3, they usually think of songs, podcasts, and other compressed audio files. While it’s worth acknowledging the role these uncompressed files have played in the world of music, the goal of this guide is to explain in detail what’s behind these files, how they work, and what makes them so popular. Through this understanding guide, we hope to cover the core concepts behind the MP3 audio format, such as bitrate and samplerate, as well as offer some tips and tricks to ensure you’re getting the best audio quality from your MP3 files.

MP3 Audio Format
MP3 Audio Format

What is MP3 Format?

MP3 is a digital audio format used to compress audio files without losing quality. This is made possible by an audio compression algorithm called MPEG-1 Audio Layer 3, also known as MP3. Compression technology involves reducing the amount of data without losing the fundamental attributes of the original audio. Compressed data can be saved as a higher quality audio file in a much smaller size. This means MP3 files are easier to stream and share online.

MP3 files can be compressed at different bit rates depending on the user. Bitrate is generally in kilobits per second. For example, a 128 kbps (kilobits per second) MP3 file uses 128,000 bits to encode the audio every second. While bitrate is an important factor in determining the quality of an audio file, there are other factors as well, such as samplerate. The samplerate is the number of audio samples taken every second. An audio file recorded at a sample rate of 44.1 kHz (kilohertz) means that 44,100 audio samples were taken every second. The higher the samplerate, the better the audio quality.

The magic behind the MP3 format lies in its ability to shed unnecessary data without compromising audio quality. This is accomplished by removing inaudible components from the audio. These inaudible components are called high and low frequencies. MP3 is a lossy audio compression codec, which means that deleted data cannot be recovered. This is why an MP3 file encoded at a small size cannot recover the audio quality of a file encoded at a larger size. MP3 is an extremely popular audio format, as it allows you to compress audio files without losing quality.

How You Can Improve the Quality of MP3 Audio Files

How can you improve the quality of audio files in MP3 format? The answer to this is to use an audio conversion program like MP3gain to adjust the volume of your audio files. MP3Gain is a free and open source tool that you can use to normalize the volume of your audio and video files. This tool is not only useful for improving audio quality, but also for saving space on your hard drive, as MP3 files encoded at lower sample rate and bitrate are smaller in size.

Of course, there is a downside to MP3 audio compression. As with any type of compression, there is a chance that the audio may become distorted or lose quality. While MP3 files encoded at a small size will have lower audio quality than those encoded at a larger size, if the proper bitrate and samplerate are selected, the audio will not be excessively distorted. The key is to find the balance between file size and sound quality.

Conclusion

We hope this guide has provided you with a clear and simple explanation of the concepts behind the MP3 audio format. While this article has mainly focused on the basics and technology behind MP3 audio files, we hope we’ve also provided some helpful tips on how to get the best audio quality out of your MP3 files. Finally, it is also important to mention the importance of using an audio conversion program like MP4Gain to normalize the volume of all audio and video files.

The bitrate and its relationship with the audio quality in an MP3

The bitrate and its relationship with the audio quality in an MP3

The bitrate and its relationship with the audio quality in an MP3
The bitrate and its relationship with the audio quality in an MP3

The bitrate is a measure of the amount of audio information that is encoded per second in a compressed audio file, such as an MP3. Bit rate is measured in kilobits per second (kbps).

The bitrate and its relationship with the audio quality in an MP3
The bitrate and its relationship with the audio quality in an MP3

The higher the bitrate, the higher the audio quality. However, a larger file size will also be required to store the same amount of audio time. Therefore, it is important to choose a suitable bitrate to balance quality and file size.

For music files, a bitrate of at least 128 kbps is recommended for decent sound quality. However, if you want higher sound quality, you can go for a higher bitrate, such as 256 kbps or even 320 kbps.

For voice audio files, a bit rate of 64 kbps is sufficient for clear sound quality. However, if you want higher sound quality, you can go for a higher bitrate, such as 96 kbps or 128 kbps.

In short, bitrate is an important factor in the audio quality of an MP3 file. It is important to choose a suitable bitrate to balance quality and file size.

Also, it’s important to note that bitrate isn’t the only factor that affects the audio quality of an MP3. Other important factors include the sample rate and the number of channels. The sample rate refers to the number of times the sound is measured per second, while the number of channels refers to the number of audio channels in the file.

For example, an audio file with a bit rate of 128 kbps and a sample rate of 44.1 kHz and 2 audio channels will have higher sound quality than a file with the same bit rate but a sample rate of 22 kHz and 1 audio channel.

In conclusion, if you want to get the best audio quality from an MP3 file, it’s important not only to choose a suitable bitrate, but also to consider the sample rate and number of channels. It is advisable to choose an optimal combination of these factors to obtain the best sound quality.

In addition, it is important to mention that there are other audio formats, such as WAV, FLAC, AIFF, which, unlike MP3, are not compressed, which means that they do not lose audio quality to the compression process. However, these formats often have much larger file sizes than compressed formats like MP3.

So, if you want the best audio quality, it’s recommended to use uncompressed formats like WAV or FLAC, but it’s also important to consider storage space and compatibility with different devices and audio players. In case of opting for compressed formats, it is important to choose an appropriate bitrate and take into account other factors such as the sampling frequency and the number of channels.

In summary, bitrate is an important factor in the audio quality of an MP3 file, but it is not the only factor to consider. It is important to choose a suitable bitrate, as well as take into account the sample rate and the number of channels to obtain the best sound quality. In addition, there are other uncompressed audio formats that offer higher sound quality, but also have a larger file size.

Why are MP3 bitrates often multiples of 32? (power of 2) part 2

Why are MP3 bitrates often multiples of 32? (power of 2) part 2

MP3 Bitrate
MP3 Bitrate

Depending on the resource, VBR can be encoded by changing the bitrate between a fixed rate above each frame, or by sharing the available bits in adjacent frames (effectively producing a non-standard bitrate for the two frames combined).

MP3 Bitrate
MP3 Bitrate

the fixed frame depends on the sampling rate, 1152 samples per frame. There is no limit to the size of the frame itself, nor to the base 2 size of the frame (ie 417 bytes for a 128 kbit/s MP3 sampled at 44.1 kHz).

In the end, a file encoded at 126kbps will sound worse than a file encoded at 128kbps, and similarly a file encoded at 131kbps will sound better. However, MP3s are encoded according to the compression psychoacoustic model of a specific encoder. The amount by which a file sounds “better” or “worse” at a given bitrate largely depends on the algorithm used to implement the model, but in general higher bitrates allow for more data, presumably for rebuild a more accurate original transmission. audio signal

Why are MP3 bitrates often multiples of 32? (power of 2)

Why are MP3 bitrates often multiples of 32? (power of 2)

MP3 Bitrate
MP3 Bitrate

Some people say:

MP3 Bitrate
MP3 Bitrate

I understand why multiples of 2 often show up on computers since they are binary, but I can’t figure out how the most common mp3 bitrates (64kbps, 128kbps, 160kbps, 192kbps, 256kbps, 320kbps, etc.) also tend to follow this rule.

Since MP3 is just a sequential encoding of sound waves, why is it important to represent each second in kilobits divisible by 2?
Does a music player like iTunes continue to read the file and play the encoded sound regardless of the second limit, or does it read the file every second?
In the latter case, reading a 256kbps file requires reading slightly fewer memory pages than a 257kbps file, but the player can always read 256KB chunks, regardless of their bitrate, and just process them automatically. incremental, right, Bar?
Are 128kbps MP3 songs popular simply because it’s a generally accepted bitrate, or do they really have any advantages over 126kbps and 131kbps files, apart from a very slight difference in quality/file size?

For constant bit rate (CBR) encoding, the MPEG-1 Audio Layer III standard specifies standard bit rates of 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256 and 320 kbit/second. There are a few others defined in the MPEG-2 standard, but they are also multiples of 2 (actually all multiples of 8 in the range 8 to 160 – see the table called “Bitrate Index” in the link above) .

Technically, there is nothing that limits the MP3 bitrate to a multiple of 2, since variable bitrate encoding can be used, or a custom bitrate can be achieved using some flags not used in the MPEG specification ( although this must be implemented manually). . In order for MP3 to be MPEG-compliant, and therefore compatible with most MP3 decoders, it must have a bitrate defined by the specification, so all CBR-encoded MP3 files have a bitrate of two.

Audio bit rate, bit rate

Audio bit rate, bit rate

Mp3 bitrate
Mp3 bitrate

Bit rate refers to the number of bits (bits) transmitted per second. The unit is bps (Bit per second) The higher the bit rate, the faster the data transmission speed.

Mp3 bitrate
Mp3 bitrate

Bitrate in sound refers to the amount of binary data per unit of time after converting an analog sound signal to a digital sound signal, which is an indirect measure of audio quality.

 

Bitrate refers to the sampling rate at which digital sound is converted from analog to digital format. The higher the sampling rate, the better the quality of the restored sound. As a benchmark for the efficiency of digital music compression, bit rate indicates the rate of the number of bits bps (bit per second, bits per second) transmitted per unit of time (1 second). Kbps (in layman’s terms is 1000 bits per second) is usually used as the unit. The bit rate of digital music on CD is 1411.2 kbps (that is, to burn 1 second of CD music, 1411.2 × 1024 data bits are required), the high BIT RATE of the digital music file music means that it should be processed in a unit of time (1 second) The amount of data (BIT) is large, which means that the sound quality of the music file is good. However, when the BITRATE is high, the file size increases, which will take up a lot of memory capacity. The most commonly used bitrate for music files is 128 kbps, and MP3 files can generally use 8 to 320 kbps. In the same way, most of them are 32-256 Kbps. Of course, the wider the rate, the better, but 320 Kbps is the highest level at the moment.

 

Bitrate calculation formula
The basic algorithm is: [Bit rate] (kbps)=[file size] (bytes) X8/[time] (seconds)/1000

Special algorithm for audio files: [bit rate] (kbps) = [quantization sample point] (kHz) × [bit depth] (bit/sampling point) × [number of channels] (typically 2)

For example, the D5 drive has a capacity of 4.3G, which takes into account different audio formats, so it is calculated as 600M (so the remaining capacity is 4.3*1000-600=3700M), so the video file should not be larger than 3.7G, in this example, take The capacity of the video file is 3.446G, and the length of the video is 100 minutes (6000 seconds). The calculation result: the bit rate is approximately equal to 4933kbps.

What is a good bitrate guide for mp3 files? Part 2

What is a good bitrate guide for mp3 files? Part 2

Mp3 Bitrate
Mp3 Bitrate

To produce high-quality MP3 files of classical and jazz music, the optimal bitrate depends on the characteristics of the song.

Mp3 Bitrate
Mp3 Bitrate

Smooth jazz can usually be copied at 192kbps to create a good balance between file size and diminishing returns, although 256kbps may sound better in a home entertainment center. A classical orchestra should be 256kbps for a portable player, but if you want to burn a CD at home or in your car, a 320kbps file might be a better option.

For saturated music such as hard rock, metal, arena, pop, electronic and house music, 320 kbps will provide the best results. The higher the number of bits per second, the more complex acoustic envelope will be preserved.

If possible, it’s best to create MP3 files with variable bit rates. This allows the encoding program to determine if a particular frame of music requires the full bit rate. Otherwise, the program will reduce data retention for that frame, resulting in a smaller file without sacrificing quality. Forcing the program to “oversample” frames can produce artifacts.

While this article is intended as a general guide, he or she may be equally satisfied with a lower bitrate for a particular song or songs in general. Many factors affect our ability to judge the quality of music, not only the devices we use but also our activities while listening to it. For example, for those who listen to MP3 files while exercising or taking a walk, external noise can make it more difficult to tell the difference in quality. Conversely, audiophiles may prefer to sample at 320kbps, regardless of their equipment, type of music, or listening habits.

If you create your own MP3 files, there are other settings that affect quality. LAME is an excellent MP3 encoder that is free and has many graphical interfaces as the interface for this popular command line program. LAME allows users to adjust many settings to generate high-quality MP3 files in seconds. You can also experiment with various bitrates in your source file to find the best subjective balance between quality and file size.

What is a good bitrate guide for mp3 files?

What is a good bitrate guide for mp3 files?

Mp3 Bit Rate
Mp3 Bit Rate

(a good bitrate guideline for mp3 files?)

Mp3 Bit Rate
Mp3 Bit Rate

MP3 files are compressed audio files created from audio formats such as wave (.wav). Wave files replicate analog recordings and digital sound files at the expense of large file size, while MP3 files sacrifice some quality for a smaller footprint. There are several factors that mitigate the quality sacrifice during the conversion process. With the correct bitrate and settings, MP3 files can provide very high quality results, making them very close to the original wave files when played on portable audio players.

An mp3 player.

The balance between file size and quality is somewhat subjective. For audiophiles, any difference is noticeable. Others may simply not be able to tell the difference between a high quality MP3 file and a raw wave source. In many cases, the nuances of the sound environment will only become clearer when played through a high-quality stereo system.

MP3s are compressed digital music files that sacrifice quality for file size.
MP3 files are primarily targeted at portable audio players. In this field, high-quality MP3 files are played with incredible sound due to their small file size. With the limited memory of portable players, it makes sense that one would want MP3 files to be as small as possible while maintaining the highest possible quality.

For this, one of the most important factors when creating MP3 files is the bit rate. In general, the more bits per second that are preserved from the original file, the higher the quality of the MP3 and the larger the file size. Lower bit rates reduce size and quality. The idea is to use the bitrate for maximum realism without saving unnecessary data, which just creates larger files with no noticeable difference to the ear.

For voice recordings such as lectures or language lessons saved to waveforms, a bit rate of 32 kilobits per second (kbps) is acceptable, although 64 kbps may offer better quality, depending on the source. At 32 kbps, the sound may sound “flat”, but that’s understandable. A 64 kbps MP3 file created from a voice recording should sound nearly identical to the original.

Desaturated acoustic music with simple arrangements should work fine at 192kbps bitrate. You can choose 256 kbps if the music will be played on a high quality device. Music that falls into this category includes folk, boy band songs, easy listening, and folk music. There are also works by many classic artists such as James Taylor, Linda Longstadt, Jonny Mitchell, and Simon Garfunkel.

Audio Intro Part 3

Audio Intro Part 3

Audio Intro
Audio Intro

WAV

Audio Intro
Audio Intro

structure
file header
The WAV format follows the RIFF Resource Interchange File Format, so the WAV format is actually a three-layer relationship, which is simplified here. Its file header format is as follows:

Address Carving type content
00H-03H 4 character * 4 RIFF resource file exchange flag
04H-07H 4 unsigned int The number of bytes from the next address to the end of the file.
08H-0BH 4 character * 4 WAV file WAVE logo
0CH-0FH 4 character * 4 fmt wave file flag, the last digit is 0x20 space
10H-13H 4 unsigned int The size of the subchunk file header. For the WAV subfragment, the value is 0x10.
14H-15H 2 short unsigned Format type, when the value is 1, it means the data is linear PCM encoding
16H-17H 2 short unsigned number of channels
18H-1BH 4 int unsigned Sampling rate
1CH-1FH 4 int unsigned Wave file bytes per second = sample rate Bit depth PCM / 8 channels
20H-21H 2 short unsigned DATA data block unit length = number of channels * PCM bit depth / 8
22H-23H 2 short unsigned Bit depth PCM
24H-27H 4 character * 4 data stamp data
28H-2BH 4 unsigned int Total length of data part (bytes)
struct WAVHeader
{ char RIFF[ 4 ]; ///Resource file exchange flag RIFF unsigned LEN; ///Number of bytes from the next address to the end of the file char WAV[ 4 ]; ///WAV file flag WAVE char FMT [ 4 ]; ///Wave fmt file pointer, last digit is 0x20 space unsigned SubchunkSize; ///The size of the sub-chunk file header, for WAV this sub-chunk, the value is 0x10 DATATYPE short unsigned; / //Format type, when the value is 1, it means the data is unsigned linear PCM encoding short CH ; ///Number of unsigned channels F; ///Unsigned sample rate BYTERATE; ///Number of bytes per second of wave file = sample rate*PCM bit depth/8*Number of unsigned channels

short DATAUNITLEN; ///DATA block unit length=channel number*Bit depth PCM/8 unsigned short BITDEPTH; ///Bit depth character PCM DATA[ 4 ]; ///Data flag data unsigned DATALEN ; ///Data partial total length (bytes) };

data organization
After the file header is the data part of the WAV file. Its data organization is: the left channel value of the first sample point, the right channel value of the first sample point, …, the left channel value of the last sample point, the right channel value of the last sample point value. Each value has a bit depth of bits.

Generate a simple wav
First complete the Wav header.

WAVHeader getHeader ( int number )
{
WAV Header res; memcpy (res.RIFF, “RIFF” , sizeof (res.RIFF)); memcpy (res.WAV, “WAVE” , sizeof (res.WAV)); memcpy (res.FMT, “fmt ” , size of ( res.FMT )); res.SubchunkSize= 0x10 ; res.DATATYPE= 1 ; res.CH= 2 ; res.F=F; res.BITDEPTH=DEPTH; res.BYTERATE=res.F*res.BITDEPTH/ 8 *res.CH; res.DATAUNITLEN=res.CH*res.BITDEPTH/ 8 ; memcpy(res.DATA, “data”

 

 

 

, size of ( res.DATA ));
res.DATALEN=num*res.DATAUNITLEN;
res.LEN=res.DATALEN+ 44 -8 ; returnres; }

First, define the key name – frequency comparison table.

const double keyf[]=
{ 27.5 , 29.1352 , 30.8677 , 32.7032 , 34.6478 , 36.7081 , 38.8909 , 41.2034 , 43.6535 , 46.2493 , 48.9994 , 51.9131 , 55 , 58.2705 , 61.7354 , 65.4064 , 69.2957 , 73.4162 , 77.7817 , 82.4069 , 87.3071 , 92.4986 , 97.9989 ,

103.826 , 110 , 116.541 , 123.471 , 130.813 , 138.591 , 146.832 , 155.563 , 164.814 , 174.614 , 184.997 , 195.998 , 207.652 , 220 , 233.082 , 246.942 , 261.626 , 277.183 , 293.665 , 311.127 , 329.628 , 349.228 , 369.994 , 391.995 , 415.305 , 440

, 466.164 , 493.883 , 523.251 , 554.365 , 587.33 , 622.254 , 659.255 , 698.456 , 739.989 , 783.991 , 830.609 , 880 , 932.328 , 987.767 , 1046.5 , 1108.73 , 1174.66 , 1244.51 , 1318.51 , 1396.91 , 1479.98 , 1567.98 , 1661.22 , 1760 , 1864.66 ,

1975.53 , 2093 , 2217.46 , 2349.32 , 2489.02 , 2637.02 , 2793.83 , 2959.96 , 3135.96 , 3322.44 , 3729.31 , 3951.07 , 4186.01 } ___ { “A-0” , “A#0” , “B- 0” , “C-1” , “C#1” , “D-1” , “D#1” , “E-1” , “F-1”, “F#1”

 

, “G-1” , “G#1” , “A-1” , “A#1” , “B-1” , “C-2” , “C#2” , “D-2″ , ” D#2″ , “E-2” , “F-2” , “F#2” , “G-2” , “G#2” , “A-2” , “A#2” , “B- 2” , “C-3” , “C#3” , “D-3” , “D#3” , “E-3” , “F-3” , “F#3” , “G-3” , “sun#3” ,