A sound file format is a file format for storing audio on a computer. There are several different formats, each with its own benefits and drawbacks. The difference between formats generally has to do with storage space versus sound quality. The processor of a computer typically decodes compressed sounds into a format that can be played by the computer.
Scratch can only read MP3 and WAV sound files.
There are three main types of audio formats: uncompressed, lossless, and lossy. Uncompressed audio files are not compressed at all, much like BMP images. They reproduce the audio perfectly but take up a lot of space (around 10MB per minute), which can be precious in a Scratch project. Lossless audio files also reproduce the sound perfectly but utilize compression schemes allowing them to be about half the size of an uncompressed file. These are useful in projects because they have lower file sizes while still keeping the same sound quality.
However, the most common type is a lossy audio file. They remove parts of the audio that are harder to hear, such as extreme high and low frequencies. Lossy files also have different bitrates that change the sound quality, with the highest usually being 320kbit/s (kilobits per second) and the lowest usually used for music being 64kbit/s. Some formats also allow for a variable bitrate (VBR), which changes the bitrate as the music is more or less complex (with a limit) and these files usually have a lower filesize than those with a constant bitrate (CBR). A lossy MP3 file at 128kbit/s is about 1/11 the size of the same sound as an uncompressed audio file. The reason why that is important is that lossy audio file sizes are much lower compared to uncompressed or even lossless audio files, which can save a lot of space in a Scratch project.
List of Formats
Supported by Scratch
Below is a description of audio formats supported by Scratch:
- The most popular audio format, (also known as MPEG-3) MP3 is a lossy format playable on many devices and programs. However, due to numerous involved patents, some programs, especially open source or independently developed programs, cannot handle MP3 files as the developers do not have the resources to pay the necessary royalties.
- The default uncompressed audio format on Windows, also playable in most programs. WAV is a higher quality format than MP3, so it uses more storage.
Below is a list of other common audio formats that are not supported by Scratch:
- Apple's lossy audio format, the format of music purchased in iTunes. Has the
.m4afile extension and is playable in iTunes, on Apple devices, and on the Nintendo DSi.
- A lossy audio format developed to be an open-source alternative to MP3, often used in video games. Many wikis offer support of this audio format to be uploaded as a file.
- Microsoft's lossy audio format, playable in Windows Media Player.
- The default uncompressed audio format on Mac OS X. Often has the
- A popular open-source lossless audio format, playable in many open-source programs.
- Apple's lossless audio format, playable in iTunes. Has the extension
.m4alike AAC files and is only distinguishable using another program.
- WMA Lossless
- Microsoft's lossless audio format, playable in Windows Media Player. Has the extension
.wmalike normal WMA files and is only distinguishable using another program.
Pulse-code modulation is a method for digitally storing analog signals or sounds. It is the standard form of encoding used by computers and other electronic devices that use music. The quality of a Pulse-code modulation is determined through the sampling rate, how many times a second a sample is taken; and through the bit depth, which determines the total amount of amplitudes a value may take up.
The encoding, or more commonly known as modulation, of a sound, is simply done through taking a series of samples from a sound and stacking them back to back. A sample is defined to be the amplitude of a sound at a given time.
Now, for example, consider the sound to the right.
The sound is recorded through a series of samples, running along the x-axis. Each sample is then given an amplitude, being assigned by some algorithm. Those amplitudes are represented by ticks on the y-axis.
In the same sound, the amplitudes of the samples are:
7, 9, 11, 12, 13, 14, 14, 15, 15, 15, 14, etc...
The bit depth of this sound is 4, so each amplitude can only be represented by four bits or one nibble. Once re-written to binary, the sound now becomes:
0111, 1001, 1011, 1100, 1101, 1110, 1110, 1111, 1111, 1111, 1110, etc...
Or more formally:
This sound can now be further processed or compacted to become other files formats, like a wav sound file.
Connecting Back to Scratch
There are a few lessons to be learned from Pulse-code modulation. Having a song with double the sample rate can effectively double the overall size of a sound, due to the fact that there is now double the number of samples to store. This would cause the sound to take up more space in a project, so if space is an issue in a project, sounds with lower sample rates would be beneficial. The same rule goes with bit depth, although doubling the bit depth will increase the file size to a smaller extent.
Sounds are also displayed in Scratch's sound editor using the principles of Pulse-code modulation. On the x-axis is time, while on the y-axis is sound pressure relative to atmospheric pressure, also known as amplitude. Atmospheric pressure is defined to be at the middle of the y-axis.
Why is Scratch Limited in Format Reading?
Scratch is limited to only reading .mp3 and .wav files because part of the data that makes up the Scratch program consists of the ability to read and convert to those files. If Scratch were to have conversions and readings for every type of file, the data size of the Scratch program would increase, and therefore the online editor would take slightly longer to load (also depending on other factors). Furthermore, .mp3 and .wav files are compressed, saving data space within the 50MB file size limit of a Scratch project.