
Dev in Aus 🇦🇺 Building with #ElixirLang
- Tweets448
- Following361
- Followers291
- Likes3.7K

ALT Plaintext formatted to read as a table, outlining the WAV file specification. It reads: ``` WAV File Format: - RIFF header (1-4): "RIFF" marks riff file, 1 byte per char. - File size (5-8): 32-bit integer, overall size minus 8 bytes. - File type (9-12): "WAVE". - Format marker (13-16): "fmt " with null. - Format length (17-20): 16. - Format type (21-22): 1 for PCM, 2-byte int. - Channels (23-24): 2, 2-byte int. - Sample rate (25-28): 44100 (CD) or 48000 (DAT), 32-bit int, samples per second. - Byte rate (29-32): 176400 ((Sample Rate * BitsPerSample * Channels) / 8). - Block align (33-34): 4 ((BitsPerSample * Channels) / 8); values: 1=8-bit mono, 2=8-bit stereo/16-bit mono, 4=16-bit stereo. - Bits per sample (35-36): 16. - Data header (37-40): "data" marks data section start. - Data size (41-44): size of data section. Values shown for 16-bit stereo. ```

ALT An Elixir code sample that showcases the power of pattern matching binaries as bitstrings - in this case for a WAV audio file. The code reads: ``` <<"RIFF", chunk_size::little-size(32), "WAVE", "fmt ", subchunk1_size::little-size(32), audio_format::little-size(16), num_channels::little-size(16), sample_rate::little-size(32), byte_rate::little-size(32), block_align::little-size(16), bits_per_sample::little-size(16), data_chunk::binary>> = File.read!("./banger.wav") ```







