├── cookbook ├── log │ └── .gitignore ├── ref │ ├── append_wavefile.log │ ├── copy_wavefile.log │ ├── direct_copy_wavefile.log │ ├── extract_xml_chunk.log │ ├── .gitignore │ ├── direct_copy_float_wavefile.log │ ├── write_stereo_sine_wavefile.log │ ├── convert_fixed_to_float_wavefile.log │ ├── downmix_5_1_to_2_0_wavefile.log │ ├── downmix_7_1_4_to_5_1_wavefile.log │ ├── downmix_stereo_to_mono_wavefile.log │ ├── write_5_1_channel_sine_wavefile.log │ ├── write_mono_silence_wavefile.log │ ├── write_7_1_4_channel_sine_wavefile.log │ ├── copy_wavefile_using_fixed_point_buffer.log │ ├── display_channel_config.log │ ├── open_close_wavefile_for_reading.log │ ├── open_close_wavefile_for_writing.log │ ├── 2ch_sine.wav │ ├── 1ch_silence.wav │ ├── 5_1ch_sine.wav │ ├── looped_clip.wav │ ├── 1ch_dmx_sine.wav │ ├── 2_0ch_dmx_sine.wav │ ├── 2ch_float_sine.wav │ ├── 5_1ch_dmx_sine.wav │ ├── 7_1_4ch_sine.wav │ ├── list_errors_for_wavefiles.log │ ├── 2ch_sine_append.wav │ ├── copy_wavefile_wavinfo.log │ ├── direct_copy_float_wavefile_wavinfo.log │ ├── downmix_7_1_4_to_5_1_wavefile_wavinfo.log │ ├── write_5_1_channel_sine_wavefile_wavinfo.log │ ├── append_wavefile_wavinfo.log │ ├── convert_fixed_to_float_wavefile_wavinfo.log │ ├── direct_copy_wavefile_wavinfo.log │ ├── open_close_wavefile_for_writing_wavinfo.log │ ├── write_7_1_4_channel_sine_wavefile_wavinfo.log │ ├── copy_parts_of_wavefile_wavinfo.log │ ├── write_mono_silence_wavefile_wavinfo.log │ ├── write_stereo_sine_wavefile_wavinfo.log │ ├── downmix_5_1_to_2_0_wavefile_wavinfo.log │ ├── copy_wavefile_using_fixed_point_buffer_wavinfo.log │ ├── display_riff_chunks.log │ ├── downmix_stereo_to_mono_wavefile_wavinfo.log │ ├── display_errors_for_wavefiles.log │ ├── read_to_memory_per_channel.log │ ├── read_to_memory_channel_interleaved.log │ ├── copy_parts_of_wavefile.log │ └── 2020-08-09.xml ├── out │ └── .gitignore ├── src │ └── .gitignore ├── .gitignore ├── data │ ├── 2020-08-09.wav │ ├── 2ch_8bit_sine.wav │ └── 2ch_silence.wav ├── README.md └── cookbook.gpr ├── test ├── simple_benchmarking │ ├── .gitignore │ ├── simple_benchmarking.gpr │ └── src │ │ ├── wavefile_benchmarking-statistics.ads │ │ ├── time_span_conversions.ads │ │ ├── wavefile_benchmarking.ads │ │ ├── time_span_conversions.adb │ │ ├── wavefile_benchmarking-statistics.adb │ │ ├── simple_benchmarking.adb │ │ └── write_random_noise_wavefile.adb ├── wavefiles_test │ ├── wavefiles_test.gpr │ ├── src │ │ ├── generic_fixed_pcm_buffer_ops.ads │ │ ├── generic_float_pcm_buffer_ops.ads │ │ ├── wave_test_instances.ads │ │ ├── generic_fixed_wave_test.ads │ │ ├── generic_float_wave_test.ads │ │ ├── generic_fixed_pcm_buffer_ops.adb │ │ └── generic_float_pcm_buffer_ops.adb │ └── src.prep │ │ ├── generic_NUM_TYPE_pcm_buffer_ops.ads │ │ ├── generic_NUM_TYPE_wave_test.ads │ │ └── generic_NUM_TYPE_pcm_buffer_ops.adb └── quick_wav_data_check │ ├── src │ ├── quick_wav_data_check.ads │ ├── quick_wav_data_checks.ads │ ├── quick_wav_data_checks-fixed_checks.ads │ ├── quick_wav_data_checks-float_checks.ads │ ├── quick_wav_data_check.adb │ └── quick_wav_data_checks.adb │ ├── quick_wav_data_check.gpr │ └── src.prep │ └── quick_wav_data_checks-NUM_TYPE_checks.ads ├── .gitignore ├── scripts ├── simple_benchmarking.sh ├── install_deps.ps1 ├── install_deps.sh └── generate_src.sh ├── alire.toml ├── .travis.yml ├── CONTRIBUTING.md ├── LICENSE ├── .travis ├── gnat_community_install.sh └── travis_run.sh ├── .github └── workflows │ ├── gnat-ce-2020-windows-19.yml │ ├── gnat-ce-2020-macos-10.yml │ ├── gnat-10-ubuntu-20.yml │ ├── gnat-7-ubuntu-18.yml │ ├── gnat-8-ubuntu-20.yml │ ├── gnat-9-ubuntu-20.yml │ └── gnat-ce-2020-ubuntu-20.yml ├── audio_wavefiles.gpr ├── src ├── audio-riff-wav.ads ├── audio-wavefiles-write.ads ├── audio-riff-wav-formats-report.ads ├── audio-wavefiles-report.ads ├── audio-wavefiles-read.ads ├── audio-wavefiles-generic_fixed_pcm_io.ads ├── audio-wavefiles-generic_float_pcm_io.ads ├── audio-wavefiles-data_types-text_io.ads ├── audio-wavefiles-generic_fixed_wav_io.ads ├── audio-wavefiles-generic_float_wav_io.ads ├── audio-wavefiles-internals.ads ├── audio-wavefiles-generic_fixed_wav_fixed_pcm_io.ads ├── audio-wavefiles-generic_fixed_wav_float_pcm_io.ads ├── audio-wavefiles-generic_float_wav_fixed_pcm_io.ads ├── audio-wavefiles-generic_float_wav_float_pcm_io.ads ├── audio-wavefiles-generic_direct_fixed_wav_io.adb ├── audio-wavefiles-generic_direct_float_wav_io.adb ├── audio-riff-wav-formats-standard_channel_configurations.adb ├── audio-wavefiles-generic_direct_float_wav_io.ads └── audio-wavefiles-generic_direct_fixed_wav_io.ads └── src.prep ├── audio-wavefiles-generic_NUM_TYPE_pcm_io.ads ├── audio-wavefiles-generic_NUM_TYPE_wav_io.ads ├── audio-wavefiles-generic_direct_NUM_TYPE_wav_io.adb ├── audio-wavefiles-generic_direct_NUM_TYPE_wav_io.ads └── audio-wavefiles-generic_NUM_TYPE_wav_NUM_TYPE_2_pcm_io.ads /cookbook/log/.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | -------------------------------------------------------------------------------- /cookbook/ref/append_wavefile.log: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cookbook/ref/copy_wavefile.log: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cookbook/out/.gitignore: -------------------------------------------------------------------------------- 1 | *.* 2 | 3 | -------------------------------------------------------------------------------- /cookbook/ref/direct_copy_wavefile.log: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cookbook/ref/extract_xml_chunk.log: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cookbook/ref/.gitignore: -------------------------------------------------------------------------------- 1 | diff*.log 2 | 3 | -------------------------------------------------------------------------------- /cookbook/ref/direct_copy_float_wavefile.log: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cookbook/ref/write_stereo_sine_wavefile.log: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cookbook/src/.gitignore: -------------------------------------------------------------------------------- 1 | *.adb 2 | *.ads 3 | -------------------------------------------------------------------------------- /cookbook/.gitignore: -------------------------------------------------------------------------------- 1 | /*.log 2 | /cookbook.ada 3 | -------------------------------------------------------------------------------- /cookbook/ref/convert_fixed_to_float_wavefile.log: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cookbook/ref/downmix_5_1_to_2_0_wavefile.log: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cookbook/ref/downmix_7_1_4_to_5_1_wavefile.log: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cookbook/ref/downmix_stereo_to_mono_wavefile.log: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cookbook/ref/write_5_1_channel_sine_wavefile.log: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cookbook/ref/write_mono_silence_wavefile.log: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/simple_benchmarking/.gitignore: -------------------------------------------------------------------------------- 1 | *.wav 2 | -------------------------------------------------------------------------------- /cookbook/ref/write_7_1_4_channel_sine_wavefile.log: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cookbook/ref/copy_wavefile_using_fixed_point_buffer.log: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cookbook/ref/display_channel_config.log: -------------------------------------------------------------------------------- 1 | 7.1.4 channels 2 | -------------------------------------------------------------------------------- /cookbook/ref/open_close_wavefile_for_reading.log: -------------------------------------------------------------------------------- 1 | File is open! 2 | File is closed! 3 | -------------------------------------------------------------------------------- /cookbook/ref/open_close_wavefile_for_writing.log: -------------------------------------------------------------------------------- 1 | File is open! 2 | File is closed! 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | lib 3 | obj 4 | deps 5 | /*.wav 6 | 7 | # Alire 8 | alire 9 | alire.lock 10 | -------------------------------------------------------------------------------- /cookbook/ref/2ch_sine.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ada-Audio/audio_wavefiles/HEAD/cookbook/ref/2ch_sine.wav -------------------------------------------------------------------------------- /cookbook/data/2020-08-09.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ada-Audio/audio_wavefiles/HEAD/cookbook/data/2020-08-09.wav -------------------------------------------------------------------------------- /cookbook/ref/1ch_silence.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ada-Audio/audio_wavefiles/HEAD/cookbook/ref/1ch_silence.wav -------------------------------------------------------------------------------- /cookbook/ref/5_1ch_sine.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ada-Audio/audio_wavefiles/HEAD/cookbook/ref/5_1ch_sine.wav -------------------------------------------------------------------------------- /cookbook/ref/looped_clip.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ada-Audio/audio_wavefiles/HEAD/cookbook/ref/looped_clip.wav -------------------------------------------------------------------------------- /cookbook/data/2ch_8bit_sine.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ada-Audio/audio_wavefiles/HEAD/cookbook/data/2ch_8bit_sine.wav -------------------------------------------------------------------------------- /cookbook/data/2ch_silence.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ada-Audio/audio_wavefiles/HEAD/cookbook/data/2ch_silence.wav -------------------------------------------------------------------------------- /cookbook/ref/1ch_dmx_sine.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ada-Audio/audio_wavefiles/HEAD/cookbook/ref/1ch_dmx_sine.wav -------------------------------------------------------------------------------- /cookbook/ref/2_0ch_dmx_sine.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ada-Audio/audio_wavefiles/HEAD/cookbook/ref/2_0ch_dmx_sine.wav -------------------------------------------------------------------------------- /cookbook/ref/2ch_float_sine.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ada-Audio/audio_wavefiles/HEAD/cookbook/ref/2ch_float_sine.wav -------------------------------------------------------------------------------- /cookbook/ref/5_1ch_dmx_sine.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ada-Audio/audio_wavefiles/HEAD/cookbook/ref/5_1ch_dmx_sine.wav -------------------------------------------------------------------------------- /cookbook/ref/7_1_4ch_sine.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ada-Audio/audio_wavefiles/HEAD/cookbook/ref/7_1_4ch_sine.wav -------------------------------------------------------------------------------- /cookbook/ref/list_errors_for_wavefiles.log: -------------------------------------------------------------------------------- 1 | Errors: 2 | - WAVEFILE_ERROR_FILE_ALREADY_OPEN 3 | 4 | No warnings! 5 | 6 | -------------------------------------------------------------------------------- /cookbook/ref/2ch_sine_append.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ada-Audio/audio_wavefiles/HEAD/cookbook/ref/2ch_sine_append.wav -------------------------------------------------------------------------------- /scripts/simple_benchmarking.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 4 | 5 | ( CPU_MHZ=`lscpu | grep "CPU MHz" | sed -e 's#CPU MHz:##'` && ./test/simple_benchmarking/obj/simple_benchmarking $CPU_MHZ ) 6 | -------------------------------------------------------------------------------- /scripts/install_deps.ps1: -------------------------------------------------------------------------------- 1 | if ( Test-Path -Path '.\deps\audio_base' -PathType Container ) 2 | { 3 | "Using available component!" 4 | } 5 | else 6 | { 7 | New-Item -Path ".\deps" -ItemType Directory 8 | 9 | git clone --branch release/1.0 https://github.com/Ada-Audio/audio_base ".\deps\audio_base" 10 | } 11 | -------------------------------------------------------------------------------- /scripts/install_deps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | if [ -d deps/audio_base ] 6 | then 7 | echo "Using existing audio_base component" 8 | else 9 | mkdir -p deps 10 | (cd deps && git clone --branch release/1.0 https://github.com/Ada-Audio/audio_base ) 11 | fi 12 | 13 | export AUDIO_BASE_PATH="$(cd deps/audio_base && pwd)" 14 | export GPR_PROJECT_PATH="$AUDIO_BASE_PATH" 15 | -------------------------------------------------------------------------------- /cookbook/ref/copy_wavefile_wavinfo.log: -------------------------------------------------------------------------------- 1 | Header info for: ./out/2ch_sine.wav 2 | WaveHeader Size: 12 3 | ChunkHeader Size: 8 4 | FormatChunk Size: 16 5 | RIFF ID: RIFF 6 | Total Size: 35316 7 | Wave ID: WAVE 8 | Chunk ID: fmt 9 | Chunk Size: 18 10 | Compression format is of type: 1 11 | Channels: 2 12 | Sample Rate: 44100 13 | Bytes / Sec: 176400 14 | wBlockAlign: 4 15 | Bits Per Sample Point: 16 16 | in size compare 17 | wavDataPtr: 46 18 | wavDataSize: 35280 19 | 20 | -------------------------------------------------------------------------------- /cookbook/ref/direct_copy_float_wavefile_wavinfo.log: -------------------------------------------------------------------------------- 1 | Header info for: ./out/2ch_float_sine.wav 2 | WaveHeader Size: 12 3 | ChunkHeader Size: 8 4 | FormatChunk Size: 16 5 | RIFF ID: RIFF 6 | Total Size: 70596 7 | Wave ID: WAVE 8 | Chunk ID: fmt 9 | Chunk Size: 40 10 | Compression format is of type: -2 11 | Channels: 2 12 | Sample Rate: 44100 13 | Bytes / Sec: 352800 14 | wBlockAlign: 8 15 | Bits Per Sample Point: 32 16 | Loading compressed wave data is not supported. 17 | -------------------------------------------------------------------------------- /cookbook/ref/downmix_7_1_4_to_5_1_wavefile_wavinfo.log: -------------------------------------------------------------------------------- 1 | Header info for: ./out/5_1ch_dmx_sine.wav 2 | WaveHeader Size: 12 3 | ChunkHeader Size: 8 4 | FormatChunk Size: 16 5 | RIFF ID: RIFF 6 | Total Size: 28836 7 | Wave ID: WAVE 8 | Chunk ID: fmt 9 | Chunk Size: 40 10 | Compression format is of type: -2 11 | Channels: 6 12 | Sample Rate: 12000 13 | Bytes / Sec: 144000 14 | wBlockAlign: 12 15 | Bits Per Sample Point: 16 16 | Loading compressed wave data is not supported. 17 | -------------------------------------------------------------------------------- /cookbook/ref/write_5_1_channel_sine_wavefile_wavinfo.log: -------------------------------------------------------------------------------- 1 | Header info for: ./out/5_1ch_sine.wav 2 | WaveHeader Size: 12 3 | ChunkHeader Size: 8 4 | FormatChunk Size: 16 5 | RIFF ID: RIFF 6 | Total Size: 105876 7 | Wave ID: WAVE 8 | Chunk ID: fmt 9 | Chunk Size: 40 10 | Compression format is of type: -2 11 | Channels: 6 12 | Sample Rate: 44100 13 | Bytes / Sec: 529200 14 | wBlockAlign: 12 15 | Bits Per Sample Point: 16 16 | Loading compressed wave data is not supported. 17 | -------------------------------------------------------------------------------- /cookbook/ref/append_wavefile_wavinfo.log: -------------------------------------------------------------------------------- 1 | Header info for: ./out/2ch_sine_append.wav 2 | WaveHeader Size: 12 3 | ChunkHeader Size: 8 4 | FormatChunk Size: 16 5 | RIFF ID: RIFF 6 | Total Size: 70596 7 | Wave ID: WAVE 8 | Chunk ID: fmt 9 | Chunk Size: 18 10 | Compression format is of type: 1 11 | Channels: 2 12 | Sample Rate: 44100 13 | Bytes / Sec: 176400 14 | wBlockAlign: 4 15 | Bits Per Sample Point: 16 16 | in size compare 17 | wavDataPtr: 46 18 | wavDataSize: 70560 19 | 20 | -------------------------------------------------------------------------------- /cookbook/ref/convert_fixed_to_float_wavefile_wavinfo.log: -------------------------------------------------------------------------------- 1 | Header info for: ./out/2ch_float_sine.wav 2 | WaveHeader Size: 12 3 | ChunkHeader Size: 8 4 | FormatChunk Size: 16 5 | RIFF ID: RIFF 6 | Total Size: 70596 7 | Wave ID: WAVE 8 | Chunk ID: fmt 9 | Chunk Size: 40 10 | Compression format is of type: -2 11 | Channels: 2 12 | Sample Rate: 44100 13 | Bytes / Sec: 352800 14 | wBlockAlign: 8 15 | Bits Per Sample Point: 32 16 | Loading compressed wave data is not supported. 17 | -------------------------------------------------------------------------------- /cookbook/ref/direct_copy_wavefile_wavinfo.log: -------------------------------------------------------------------------------- 1 | Header info for: ./out/2ch_sine.wav 2 | WaveHeader Size: 12 3 | ChunkHeader Size: 8 4 | FormatChunk Size: 16 5 | RIFF ID: RIFF 6 | Total Size: 35316 7 | Wave ID: WAVE 8 | Chunk ID: fmt 9 | Chunk Size: 18 10 | Compression format is of type: 1 11 | Channels: 2 12 | Sample Rate: 44100 13 | Bytes / Sec: 176400 14 | wBlockAlign: 4 15 | Bits Per Sample Point: 16 16 | in size compare 17 | wavDataPtr: 46 18 | wavDataSize: 35280 19 | 20 | -------------------------------------------------------------------------------- /cookbook/ref/open_close_wavefile_for_writing_wavinfo.log: -------------------------------------------------------------------------------- 1 | Header info for: ./out/test.wav 2 | WaveHeader Size: 12 3 | ChunkHeader Size: 8 4 | FormatChunk Size: 16 5 | RIFF ID: RIFF 6 | Total Size: 36 7 | Wave ID: WAVE 8 | Chunk ID: fmt 9 | Chunk Size: 18 10 | Compression format is of type: 1 11 | Channels: 2 12 | Sample Rate: 44100 13 | Bytes / Sec: 176400 14 | wBlockAlign: 4 15 | Bits Per Sample Point: 16 16 | in size compare 17 | wavDataPtr: 46 18 | wavDataSize: 0 19 | 20 | -------------------------------------------------------------------------------- /cookbook/ref/write_7_1_4_channel_sine_wavefile_wavinfo.log: -------------------------------------------------------------------------------- 1 | Header info for: ./out/7_1_4ch_sine.wav 2 | WaveHeader Size: 12 3 | ChunkHeader Size: 8 4 | FormatChunk Size: 16 5 | RIFF ID: RIFF 6 | Total Size: 57636 7 | Wave ID: WAVE 8 | Chunk ID: fmt 9 | Chunk Size: 40 10 | Compression format is of type: -2 11 | Channels: 12 12 | Sample Rate: 12000 13 | Bytes / Sec: 288000 14 | wBlockAlign: 24 15 | Bits Per Sample Point: 16 16 | Loading compressed wave data is not supported. 17 | -------------------------------------------------------------------------------- /cookbook/ref/copy_parts_of_wavefile_wavinfo.log: -------------------------------------------------------------------------------- 1 | Header info for: ./out/looped_clip.wav 2 | WaveHeader Size: 12 3 | ChunkHeader Size: 8 4 | FormatChunk Size: 16 5 | RIFF ID: RIFF 6 | Total Size: 40596 7 | Wave ID: WAVE 8 | Chunk ID: fmt 9 | Chunk Size: 18 10 | Compression format is of type: 1 11 | Channels: 2 12 | Sample Rate: 48000 13 | Bytes / Sec: 192000 14 | wBlockAlign: 4 15 | Bits Per Sample Point: 16 16 | in size compare 17 | wavDataPtr: 46 18 | wavDataSize: 40560 19 | 20 | -------------------------------------------------------------------------------- /cookbook/ref/write_mono_silence_wavefile_wavinfo.log: -------------------------------------------------------------------------------- 1 | Header info for: ./out/1ch_silence.wav 2 | WaveHeader Size: 12 3 | ChunkHeader Size: 8 4 | FormatChunk Size: 16 5 | RIFF ID: RIFF 6 | Total Size: 8856 7 | Wave ID: WAVE 8 | Chunk ID: fmt 9 | Chunk Size: 18 10 | Compression format is of type: 1 11 | Channels: 1 12 | Sample Rate: 44100 13 | Bytes / Sec: 88200 14 | wBlockAlign: 2 15 | Bits Per Sample Point: 16 16 | in size compare 17 | wavDataPtr: 46 18 | wavDataSize: 8820 19 | 20 | -------------------------------------------------------------------------------- /cookbook/ref/write_stereo_sine_wavefile_wavinfo.log: -------------------------------------------------------------------------------- 1 | Header info for: ./out/2ch_sine.wav 2 | WaveHeader Size: 12 3 | ChunkHeader Size: 8 4 | FormatChunk Size: 16 5 | RIFF ID: RIFF 6 | Total Size: 35316 7 | Wave ID: WAVE 8 | Chunk ID: fmt 9 | Chunk Size: 18 10 | Compression format is of type: 1 11 | Channels: 2 12 | Sample Rate: 44100 13 | Bytes / Sec: 176400 14 | wBlockAlign: 4 15 | Bits Per Sample Point: 16 16 | in size compare 17 | wavDataPtr: 46 18 | wavDataSize: 35280 19 | 20 | -------------------------------------------------------------------------------- /cookbook/ref/downmix_5_1_to_2_0_wavefile_wavinfo.log: -------------------------------------------------------------------------------- 1 | Header info for: ./out/2_0ch_dmx_sine.wav 2 | WaveHeader Size: 12 3 | ChunkHeader Size: 8 4 | FormatChunk Size: 16 5 | RIFF ID: RIFF 6 | Total Size: 35316 7 | Wave ID: WAVE 8 | Chunk ID: fmt 9 | Chunk Size: 18 10 | Compression format is of type: 1 11 | Channels: 2 12 | Sample Rate: 44100 13 | Bytes / Sec: 176400 14 | wBlockAlign: 4 15 | Bits Per Sample Point: 16 16 | in size compare 17 | wavDataPtr: 46 18 | wavDataSize: 35280 19 | 20 | -------------------------------------------------------------------------------- /cookbook/ref/copy_wavefile_using_fixed_point_buffer_wavinfo.log: -------------------------------------------------------------------------------- 1 | Header info for: ./out/2ch_sine.wav 2 | WaveHeader Size: 12 3 | ChunkHeader Size: 8 4 | FormatChunk Size: 16 5 | RIFF ID: RIFF 6 | Total Size: 35316 7 | Wave ID: WAVE 8 | Chunk ID: fmt 9 | Chunk Size: 18 10 | Compression format is of type: 1 11 | Channels: 2 12 | Sample Rate: 44100 13 | Bytes / Sec: 176400 14 | wBlockAlign: 4 15 | Bits Per Sample Point: 16 16 | in size compare 17 | wavDataPtr: 46 18 | wavDataSize: 35280 19 | 20 | -------------------------------------------------------------------------------- /cookbook/ref/display_riff_chunks.log: -------------------------------------------------------------------------------- 1 | ---- RIFF Chunks Information ---- 2 | Id: RIFF_IDENTIFIER_STANDARD 3 | Format: RIFF_FORMAT_WAVE 4 | Chunk count: 2 5 | 6 | - ID: fmt 7 | Internal tag: WAV_CHUNK_FMT 8 | Size: 16 9 | Start index: 13 10 | Consolidated: TRUE 11 | 12 | - ID: data 13 | Internal tag: WAV_CHUNK_DATA 14 | Size: 176 15 | Start index: 37 16 | Consolidated: TRUE 17 | 18 | --------------------------------- 19 | -------------------------------------------------------------------------------- /cookbook/ref/downmix_stereo_to_mono_wavefile_wavinfo.log: -------------------------------------------------------------------------------- 1 | Header info for: ./out/1ch_dmx_sine.wav 2 | WaveHeader Size: 12 3 | ChunkHeader Size: 8 4 | FormatChunk Size: 16 5 | RIFF ID: RIFF 6 | Total Size: 17676 7 | Wave ID: WAVE 8 | Chunk ID: fmt 9 | Chunk Size: 18 10 | Compression format is of type: 1 11 | Channels: 1 12 | Sample Rate: 44100 13 | Bytes / Sec: 88200 14 | wBlockAlign: 2 15 | Bits Per Sample Point: 16 16 | in size compare 17 | wavDataPtr: 46 18 | wavDataSize: 17640 19 | 20 | -------------------------------------------------------------------------------- /cookbook/README.md: -------------------------------------------------------------------------------- 1 | Ada Wavefile Library: Cookbook 2 | ============================== 3 | 4 | The [cookbook](cookbook.md) file contains a list of source-code examples for 5 | various use-cases — starting from the simplest ones to more complicated 6 | use-cases. 7 | 8 | The cookbook file is written in Markdown syntax. You can create a PDF document 9 | for it using [pandoc](https://pandoc.org). For example: 10 | 11 | ```sh 12 | pandoc --highlight-style tango -o cookbook.pdf cookbook.md 13 | ``` 14 | -------------------------------------------------------------------------------- /alire.toml: -------------------------------------------------------------------------------- 1 | description = "Ada Wavefile Library" 2 | long-description = """ 3 | # Ada Wavefile Library 4 | 5 | This crate contains Ada packages for wavefile I/O. 6 | """ 7 | name = "audio_wavefiles" 8 | version = "2.0.0" 9 | website="https://github.com/Ada-Audio/audio_wavefiles" 10 | licenses = ["MIT"] 11 | authors=["Gustavo A. Hoffmann"] 12 | maintainers = ["gusthoff@gusthoff.com"] 13 | maintainers-logins = ["gusthoff"] 14 | project-files = ["audio_wavefiles.gpr"] 15 | tags = ["audio", "riff", "wavefiles"] 16 | 17 | [[depends-on]] 18 | audio_base = "~1.0" 19 | -------------------------------------------------------------------------------- /cookbook/ref/display_errors_for_wavefiles.log: -------------------------------------------------------------------------------- 1 | ---------------- Wavefile errors ---------------- 2 | 3 | 4 | ------------------------------------------------- 5 | -------------- Wavefile warnings ---------------- 6 | 7 | - Inconsistent channel mask 8 | 9 | ------------------------------------------------- 10 | ---------------- Wavefile errors ---------------- 11 | 12 | - File already open 13 | 14 | ------------------------------------------------- 15 | -------------- Wavefile warnings ---------------- 16 | 17 | 18 | ------------------------------------------------- 19 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | env: 2 | global: 3 | - TOOLS_DIR=$HOME/build_tools 4 | - GNAT_INSTALLER_PATH=$TOOLS_DIR/gnat-2020-20200818-x86_64-linux-bin 5 | - GNAT_PATH=$TOOLS_DIR/gnat-2020-x86_64-linux-bin 6 | 7 | language: minimal 8 | 9 | os: 10 | - linux 11 | 12 | dist: focal 13 | 14 | cache: 15 | directories: 16 | - $HOME/build_tools 17 | 18 | before_install: 19 | - sudo apt-get update 20 | - sudo apt-get -y install wavbreaker 21 | 22 | install: ./.travis/gnat_community_install.sh 23 | 24 | jobs: 25 | include: 26 | - name: "Run all tests" 27 | script: 28 | - ./.travis/travis_run.sh 29 | -------------------------------------------------------------------------------- /cookbook/ref/read_to_memory_per_channel.log: -------------------------------------------------------------------------------- 1 | Channel # 1 2 | Sample # 0: 3.13110E-02 3 | Sample # 1: 6.25305E-02 4 | Sample # 2: 9.34753E-02 5 | Sample # 3: 1.24054E-01 6 | Sample # 4: 1.54175E-01 7 | Sample # 5: 1.83655E-01 8 | Sample # 6: 2.12433E-01 9 | Sample # 7: 2.40387E-01 10 | Sample # 8: 2.67365E-01 11 | Sample # 9: 2.93304E-01 12 | Channel # 2 13 | Sample # 0: 7.84302E-03 14 | Sample # 1: 1.56555E-02 15 | Sample # 2: 2.34680E-02 16 | Sample # 3: 3.12500E-02 17 | Sample # 4: 3.90320E-02 18 | Sample # 5: 4.67529E-02 19 | Sample # 6: 5.44128E-02 20 | Sample # 7: 6.20422E-02 21 | Sample # 8: 6.95801E-02 22 | Sample # 9: 7.70874E-02 23 | -------------------------------------------------------------------------------- /cookbook/ref/read_to_memory_channel_interleaved.log: -------------------------------------------------------------------------------- 1 | Sample # 0 2 | Channel # 1: 3.13110E-02 3 | Channel # 2: 7.84302E-03 4 | Sample # 1 5 | Channel # 1: 6.25305E-02 6 | Channel # 2: 1.56555E-02 7 | Sample # 2 8 | Channel # 1: 9.34753E-02 9 | Channel # 2: 2.34680E-02 10 | Sample # 3 11 | Channel # 1: 1.24054E-01 12 | Channel # 2: 3.12500E-02 13 | Sample # 4 14 | Channel # 1: 1.54175E-01 15 | Channel # 2: 3.90320E-02 16 | Sample # 5 17 | Channel # 1: 1.83655E-01 18 | Channel # 2: 4.67529E-02 19 | Sample # 6 20 | Channel # 1: 2.12433E-01 21 | Channel # 2: 5.44128E-02 22 | Sample # 7 23 | Channel # 1: 2.40387E-01 24 | Channel # 2: 6.20422E-02 25 | Sample # 8 26 | Channel # 1: 2.67365E-01 27 | Channel # 2: 6.95801E-02 28 | Sample # 9 29 | Channel # 1: 2.93304E-01 30 | Channel # 2: 7.70874E-02 31 | -------------------------------------------------------------------------------- /test/wavefiles_test/wavefiles_test.gpr: -------------------------------------------------------------------------------- 1 | with "audio_wavefiles.gpr"; 2 | 3 | project Wavefiles_Test is 4 | 5 | for Source_Dirs use ("src/**"); 6 | for Object_Dir use "./obj"; 7 | for Exec_Dir use "./bin"; 8 | for Create_Missing_Dirs use "True"; 9 | for Main use ("wavefiles_test.adb"); 10 | 11 | package Ide is 12 | for Vcs_Kind use "git"; 13 | for Documentation_Dir use "./doc"; 14 | end Ide; 15 | 16 | package Compiler is 17 | for Default_Switches ("ada") use ("-gnata", "-gnato", "-fstack-check", "-g", "-gnatQ", "-gnatVa", "-gnatwa", "-gnaty3ABIL4M79OSabcdefhiklnprstux"); 18 | end Compiler; 19 | 20 | package Linker is 21 | for Default_Switches ("ada") use ("-g"); 22 | end Linker; 23 | 24 | package Builder is 25 | for Default_Switches ("ada") use ("-g", "-s"); 26 | end Builder; 27 | 28 | package Pretty_Printer is 29 | for Default_Switches ("ada") use ("-A0", "-A1", "-A2", "-A3", "-A4", "-A5", "-c4", "-c3", "--separate-loop-then"); 30 | end Pretty_Printer; 31 | 32 | end Wavefiles_Test; 33 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to the audio_wavefiles project 2 | 3 | ## Automatically generated source-code files 4 | 5 | This project contains automatically generated source-code files. You can find 6 | them in the `src.prep` directories. It is expected that changes intended for 7 | automatically generated files are made in the templates from the `src.prep` 8 | directories, not in the automatically generated files themselves. Also, a 9 | continuous integration test verifies that those files are "in sync." 10 | 11 | ## Testing 12 | 13 | Before creating a pull request to this project, please make sure that all tests 14 | are passing. Pull requests with failing tests won't be considered for 15 | integration. 16 | 17 | This project makes use of continuous integration infrastructure from GitHub and 18 | Travis-CI. You can verify the tests results using this infrastructure. 19 | 20 | ## Code of conduct 21 | 22 | Although this project doesn't have an official code of conduct, it is expected 23 | that behaviors such as using welcoming and inclusive language or being 24 | respectful of differing viewpoints and experiences are observed. 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 -- 2021 Gustavo A. Hoffmann (gusthoff) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /.travis/gnat_community_install.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env sh 2 | 3 | set -v 4 | set -e 5 | 6 | installer_hash=a639696a9fd3bdf0be21376cc2dc3129323cbe42 7 | installer_name=gnat-2020-20200818-x86_64-linux-bin 8 | 9 | # Create tools directory 10 | if ! test -d $TOOLS_DIR 11 | then 12 | mkdir -p $TOOLS_DIR 13 | fi 14 | 15 | # Get / update gnat_community_install_script repo 16 | if ! test -d $TOOLS_DIR/gnat_community_install_script 17 | then 18 | (cd $TOOLS_DIR && git clone https://github.com/AdaCore/gnat_community_install_script) 19 | else 20 | (cd $TOOLS_DIR/gnat_community_install_script && git pull) 21 | fi 22 | 23 | # Get GNAT 24 | if ! test -f $GNAT_INSTALLER_PATH 25 | then 26 | wget -O $GNAT_INSTALLER_PATH \ 27 | "https://community.download.adacore.com/v1/${installer_hash}?filename=${installer_name}" 28 | fi 29 | 30 | # If needed, extract GNAT 31 | if ! test -d $GNAT_PATH 32 | then 33 | (cd $TOOLS_DIR && sh gnat_community_install_script/install_package.sh $GNAT_INSTALLER_PATH $GNAT_PATH) 34 | fi 35 | 36 | export PATH=$GNAT_PATH/bin:$PATH 37 | 38 | # Log content 39 | ls $TOOLS_DIR 40 | ls $GNAT_PATH 41 | ls $GNAT_PATH/bin 42 | 43 | which gcc 44 | which gnatchop 45 | which gprbuild 46 | -------------------------------------------------------------------------------- /test/simple_benchmarking/simple_benchmarking.gpr: -------------------------------------------------------------------------------- 1 | with "audio_wavefiles.gpr"; 2 | 3 | project Simple_Benchmarking is 4 | 5 | type Build_Type is ("DEBUG", "RELEASE"); 6 | 7 | Build : Build_Type := 8 | External ("WAVEFILES_BUILD_MODE", External ("BUILD", "DEBUG")); 9 | 10 | for Source_Dirs use ("src"); 11 | for Object_Dir use "obj"; 12 | for Create_Missing_Dirs use "True"; 13 | for Main use ("simple_benchmarking.adb"); 14 | 15 | package Compiler is 16 | case Build is 17 | when "DEBUG" => 18 | for Switches ("ada") use ("-g", "-O0", 19 | "-gnata", "-gnato", "-gnatVa", 20 | "-gnatwa", "-fstack-check", "-gnaty3ACIM79Oabcdefhiklnprstux"); 21 | when "RELEASE" => 22 | for Switches ("Ada") use ("-O2", "-gnatn", "-gnatp", "-gnatwa", 23 | "-gnaty3ACIM79Oabcdefhiklnprstux"); 24 | end case; 25 | -- for Switches ("Ada") use ("-gnatp", "-O3"); 26 | end Compiler; 27 | 28 | package Pretty_Printer is 29 | for Default_Switches ("ada") use ("-A0", "-A1", "-A2", "-A3", "-A4", "-A5", "-c4", "-c3", "--separate-loop-then"); 30 | end Pretty_Printer; 31 | 32 | end Simple_Benchmarking; 33 | -------------------------------------------------------------------------------- /.github/workflows/gnat-ce-2020-windows-19.yml: -------------------------------------------------------------------------------- 1 | name: GNAT Community 2020 on Windows Server 2019 2 | 3 | on: [push, pull_request, workflow_dispatch] 4 | 5 | jobs: 6 | build: 7 | runs-on: windows-2019 8 | 9 | steps: 10 | - name: Checkout 11 | uses: actions/checkout@v2 12 | 13 | - name: Check cached GNAT toolchain 14 | uses: actions/cache@v2 15 | with: 16 | path: ./cached_gnat 17 | key: ${{ runner.os }}-gnat-ce-2020 18 | 19 | - name: Set up GNAT toolchain 20 | uses: ada-actions/toolchain@ce2020 21 | with: 22 | distrib: community 23 | target: native 24 | community_year: 2020 25 | install_dir: ./cached_gnat 26 | 27 | - name: Install dependencies 28 | run: > 29 | ./scripts/install_deps.ps1 30 | 31 | - name: Build test for Wavefile Library 32 | env: 33 | GPR_PROJECT_PATH: .\deps\audio_base 34 | run: gprbuild -P test/wavefiles_test/wavefiles_test.gpr 35 | 36 | - name: Build Quick Wav-Data Check 37 | env: 38 | GPR_PROJECT_PATH: .\deps\audio_base 39 | run: gprbuild -P test/quick_wav_data_check/quick_wav_data_check.gpr 40 | 41 | - name: Run Quick Wav-Data Check 42 | run: ./test/quick_wav_data_check/bin/quick_wav_data_check "$(date +"%Y%m%d-%H%M%S")_" 43 | -------------------------------------------------------------------------------- /.github/workflows/gnat-ce-2020-macos-10.yml: -------------------------------------------------------------------------------- 1 | name: GNAT Community 2020 on macOS 10.15 2 | 3 | on: [push, pull_request, workflow_dispatch] 4 | 5 | jobs: 6 | build: 7 | runs-on: macos-10.15 8 | 9 | steps: 10 | - name: Checkout 11 | uses: actions/checkout@v2 12 | 13 | - name: Check cached GNAT toolchain 14 | uses: actions/cache@v2 15 | with: 16 | path: ./cached_gnat 17 | key: ${{ runner.os }}-gnat-ce-2020 18 | 19 | - name: Set up GNAT toolchain 20 | uses: ada-actions/toolchain@ce2020 21 | with: 22 | distrib: community 23 | target: native 24 | community_year: 2020 25 | install_dir: ./cached_gnat 26 | 27 | - name: Install dependencies 28 | run: > 29 | . ./scripts/install_deps.sh && 30 | echo "GPR_PROJECT_PATH=${GPR_PROJECT_PATH}" >> $GITHUB_ENV 31 | 32 | - name: Verify generated source-code files 33 | run: TEST=1 ./scripts/generate_src.sh 34 | 35 | - name: Build test for Wavefile Library 36 | run: gprbuild -P test/wavefiles_test/wavefiles_test.gpr 37 | 38 | - name: Build Quick Wav-Data Check 39 | run: gprbuild -P test/quick_wav_data_check/quick_wav_data_check.gpr 40 | 41 | - name: Run Quick Wav-Data Check 42 | run: ./test/quick_wav_data_check/bin/quick_wav_data_check "$(date +"%Y%m%d-%H%M%S")_" 43 | -------------------------------------------------------------------------------- /.github/workflows/gnat-10-ubuntu-20.yml: -------------------------------------------------------------------------------- 1 | name: GNAT 10 on Ubuntu 20.04 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-20.04 8 | 9 | steps: 10 | - name: Checkout 11 | uses: actions/checkout@v2 12 | 13 | - name: Set up GNAT toolchain 14 | run: > 15 | sudo apt-get update && 16 | sudo apt-get install gnat-10 gprbuild && 17 | sudo apt-get install wavbreaker 18 | 19 | - name: Install dependencies 20 | run: > 21 | . ./scripts/install_deps.sh && 22 | echo "GPR_PROJECT_PATH=${GPR_PROJECT_PATH}" >> $GITHUB_ENV 23 | 24 | - name: Verify generated source-code files 25 | run: TEST=1 ./scripts/generate_src.sh 26 | 27 | - name: Build test for Wavefile Library 28 | run: gprbuild -P test/wavefiles_test/wavefiles_test.gpr 29 | 30 | - name: Build Quick Wav-Data Check 31 | run: gprbuild -P test/quick_wav_data_check/quick_wav_data_check.gpr 32 | 33 | - name: Run Quick Wav-Data Check 34 | run: ./test/quick_wav_data_check/bin/quick_wav_data_check "$(date +"%Y%m%d-%H%M%S")_" 35 | 36 | - name: Build & check Cookbook 37 | run: ./scripts/test_cookbook.sh 38 | 39 | - name: Build & run Simple Benchmarking 40 | run: > 41 | gprclean -r -P test/simple_benchmarking/simple_benchmarking.gpr && 42 | gprbuild -P test/simple_benchmarking/simple_benchmarking.gpr -XWAVEFILES_BUILD_MODE=RELEASE && 43 | ./scripts/simple_benchmarking.sh 44 | -------------------------------------------------------------------------------- /.github/workflows/gnat-7-ubuntu-18.yml: -------------------------------------------------------------------------------- 1 | name: GNAT 7 on Ubuntu 18.04 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-18.04 8 | 9 | steps: 10 | - name: Checkout 11 | uses: actions/checkout@v2 12 | 13 | - name: Set up GNAT toolchain 14 | run: > 15 | sudo apt-get update && 16 | sudo apt-get install gnat-7 gprbuild && 17 | sudo apt-get install wavbreaker 18 | 19 | - name: Install dependencies 20 | run: > 21 | . ./scripts/install_deps.sh && 22 | echo "GPR_PROJECT_PATH=${GPR_PROJECT_PATH}" >> $GITHUB_ENV 23 | 24 | - name: Verify generated source-code files 25 | run: TEST=1 ./scripts/generate_src.sh 26 | 27 | - name: Build test for Wavefile Library 28 | run: gprbuild -P test/wavefiles_test/wavefiles_test.gpr 29 | 30 | - name: Build Quick Wav-Data Check 31 | run: gprbuild -P test/quick_wav_data_check/quick_wav_data_check.gpr 32 | 33 | - name: Run Quick Wav-Data Check 34 | run: ./test/quick_wav_data_check/bin/quick_wav_data_check "$(date +"%Y%m%d-%H%M%S")_" 35 | 36 | - name: Build & check Cookbook 37 | run: ./scripts/test_cookbook.sh 38 | 39 | - name: Build & run Simple Benchmarking 40 | run: > 41 | gprclean -r -P test/simple_benchmarking/simple_benchmarking.gpr && 42 | gprbuild -P test/simple_benchmarking/simple_benchmarking.gpr -XWAVEFILES_BUILD_MODE=RELEASE && 43 | ./scripts/simple_benchmarking.sh 44 | -------------------------------------------------------------------------------- /.github/workflows/gnat-8-ubuntu-20.yml: -------------------------------------------------------------------------------- 1 | name: GNAT 8 on Ubuntu 20.04 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-20.04 8 | 9 | steps: 10 | - name: Checkout 11 | uses: actions/checkout@v2 12 | 13 | - name: Set up GNAT toolchain 14 | run: > 15 | sudo apt-get update && 16 | sudo apt-get install gnat-8 gprbuild && 17 | sudo apt-get install wavbreaker 18 | 19 | - name: Install dependencies 20 | run: > 21 | . ./scripts/install_deps.sh && 22 | echo "GPR_PROJECT_PATH=${GPR_PROJECT_PATH}" >> $GITHUB_ENV 23 | 24 | - name: Verify generated source-code files 25 | run: TEST=1 ./scripts/generate_src.sh 26 | 27 | - name: Build test for Wavefile Library 28 | run: gprbuild -P test/wavefiles_test/wavefiles_test.gpr 29 | 30 | - name: Build Quick Wav-Data Check 31 | run: gprbuild -P test/quick_wav_data_check/quick_wav_data_check.gpr 32 | 33 | - name: Run Quick Wav-Data Check 34 | run: ./test/quick_wav_data_check/bin/quick_wav_data_check "$(date +"%Y%m%d-%H%M%S")_" 35 | 36 | - name: Build & check Cookbook 37 | run: ./scripts/test_cookbook.sh 38 | 39 | - name: Build & run Simple Benchmarking 40 | run: > 41 | gprclean -r -P test/simple_benchmarking/simple_benchmarking.gpr && 42 | gprbuild -P test/simple_benchmarking/simple_benchmarking.gpr -XWAVEFILES_BUILD_MODE=RELEASE && 43 | ./scripts/simple_benchmarking.sh 44 | -------------------------------------------------------------------------------- /.github/workflows/gnat-9-ubuntu-20.yml: -------------------------------------------------------------------------------- 1 | name: GNAT 9 on Ubuntu 20.04 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-20.04 8 | 9 | steps: 10 | - name: Checkout 11 | uses: actions/checkout@v2 12 | 13 | - name: Set up GNAT toolchain 14 | run: > 15 | sudo apt-get update && 16 | sudo apt-get install gnat-9 gprbuild && 17 | sudo apt-get install wavbreaker 18 | 19 | - name: Install dependencies 20 | run: > 21 | . ./scripts/install_deps.sh && 22 | echo "GPR_PROJECT_PATH=${GPR_PROJECT_PATH}" >> $GITHUB_ENV 23 | 24 | - name: Verify generated source-code files 25 | run: TEST=1 ./scripts/generate_src.sh 26 | 27 | - name: Build test for Wavefile Library 28 | run: gprbuild -P test/wavefiles_test/wavefiles_test.gpr 29 | 30 | - name: Build Quick Wav-Data Check 31 | run: gprbuild -P test/quick_wav_data_check/quick_wav_data_check.gpr 32 | 33 | - name: Run Quick Wav-Data Check 34 | run: ./test/quick_wav_data_check/bin/quick_wav_data_check "$(date +"%Y%m%d-%H%M%S")_" 35 | 36 | - name: Build & check Cookbook 37 | run: ./scripts/test_cookbook.sh 38 | 39 | - name: Build & run Simple Benchmarking 40 | run: > 41 | gprclean -r -P test/simple_benchmarking/simple_benchmarking.gpr && 42 | gprbuild -P test/simple_benchmarking/simple_benchmarking.gpr -XWAVEFILES_BUILD_MODE=RELEASE && 43 | ./scripts/simple_benchmarking.sh 44 | -------------------------------------------------------------------------------- /audio_wavefiles.gpr: -------------------------------------------------------------------------------- 1 | with "audio_base.gpr"; 2 | 3 | library project Audio_Wavefiles is 4 | 5 | type Build_Type is 6 | ("DEBUG", "RELEASE"); 7 | Build : Build_Type := external ("WAVEFILES_BUILD_MODE", external ("BUILD", "DEBUG")); 8 | 9 | for Source_Dirs use ("src/**"); 10 | for Object_Dir use "./obj"; 11 | for Create_Missing_Dirs use "True"; 12 | for Library_Name use "wavefiles"; 13 | for Library_Dir use "lib"; 14 | for Library_Version use "2.0.0"; 15 | 16 | type Library_Type_Type is ("relocatable", "static", "static-pic"); 17 | Library_Type : Library_Type_Type := 18 | external ("WAVEFILES_LIBRARY_TYPE", 19 | external ("LIBRARY_TYPE", "static")); 20 | for Library_Kind use Library_Type; 21 | 22 | package Ide is 23 | for Vcs_Kind use "git"; 24 | for Documentation_Dir use "./doc"; 25 | end Ide; 26 | 27 | package Builder is 28 | for Switches ("ada") use ("-j0", "-g"); 29 | end Builder; 30 | 31 | package Compiler is 32 | 33 | case Build is 34 | 35 | when "DEBUG" => 36 | for Switches ("ada") use ("-g", "-O0", "-gnata", "-gnato", "-fstack-check", "-gnatVa", "-gnatwa", "-gnaty3ACIM79Oabcdefhiklnprstux"); 37 | 38 | when "RELEASE" => 39 | for Switches ("Ada") use ("-O2", "-gnatn", "-gnatwa"); 40 | for Switches ("ada") use ("-g", "-O0", "-gnata", "-gnato", "-fstack-check", "-gnatVa", "-gnatwa", "-gnaty3ACIM79Oabcdefhiklnprstux"); 41 | end case; 42 | end Compiler; 43 | 44 | package Pretty_Printer is 45 | for Default_Switches ("ada") use ("-A0", "-A1", "-A2", "-A3", "-A4", "-A5", "-c4", "-c3", "--separate-loop-then"); 46 | end Pretty_Printer; 47 | 48 | package Binder is 49 | for Switches ("ada") use ("-Es"); 50 | end Binder; 51 | 52 | end Audio_Wavefiles; 53 | -------------------------------------------------------------------------------- /.github/workflows/gnat-ce-2020-ubuntu-20.yml: -------------------------------------------------------------------------------- 1 | name: GNAT Community 2020 on Ubuntu 20.04 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-20.04 8 | 9 | steps: 10 | - name: Checkout 11 | uses: actions/checkout@v2 12 | 13 | - name: Check cached GNAT toolchain 14 | uses: actions/cache@v2 15 | with: 16 | path: ./cached_gnat 17 | key: ${{ runner.os }}-gnat-ce-2020 18 | 19 | - name: Set up GNAT toolchain 20 | uses: ada-actions/toolchain@ce2020 21 | with: 22 | distrib: community 23 | target: native 24 | community_year: 2020 25 | install_dir: ./cached_gnat 26 | 27 | - name: Set up Ubuntu packages 28 | run: > 29 | sudo apt-get update && 30 | sudo apt-get install wavbreaker 31 | 32 | - name: Install dependencies 33 | run: > 34 | . ./scripts/install_deps.sh && 35 | echo "GPR_PROJECT_PATH=${GPR_PROJECT_PATH}" >> $GITHUB_ENV 36 | 37 | - name: Verify generated source-code files 38 | run: TEST=1 ./scripts/generate_src.sh 39 | 40 | - name: Build test for Wavefile Library 41 | run: gprbuild -P test/wavefiles_test/wavefiles_test.gpr 42 | 43 | - name: Build Quick Wav-Data Check 44 | run: gprbuild -P test/quick_wav_data_check/quick_wav_data_check.gpr 45 | 46 | - name: Run Quick Wav-Data Check 47 | run: ./test/quick_wav_data_check/bin/quick_wav_data_check "$(date +"%Y%m%d-%H%M%S")_" 48 | 49 | - name: Build & check Cookbook 50 | run: ./scripts/test_cookbook.sh 51 | 52 | - name: Build & run Simple Benchmarking 53 | run: > 54 | gprclean -r -P test/simple_benchmarking/simple_benchmarking.gpr && 55 | gprbuild -P test/simple_benchmarking/simple_benchmarking.gpr -XWAVEFILES_BUILD_MODE=RELEASE && 56 | ./scripts/simple_benchmarking.sh 57 | -------------------------------------------------------------------------------- /.travis/travis_run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | PATH=$GNAT_PATH/bin:$PATH 6 | 7 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 8 | cd $DIR && cd .. 9 | 10 | echo "" 11 | echo "=======================================================================" 12 | echo "Install dependencies" 13 | echo "=======================================================================" 14 | 15 | . ./scripts/install_deps.sh 16 | 17 | echo "" 18 | echo "=======================================================================" 19 | echo "Verify generated source-code files" 20 | echo "=======================================================================" 21 | 22 | TEST=1 ./scripts/generate_src.sh 23 | 24 | echo "" 25 | echo "=======================================================================" 26 | echo "Build test for Wavefile Library" 27 | echo "=======================================================================" 28 | 29 | gprbuild -P ./test/wavefiles_test/wavefiles_test.gpr 30 | 31 | echo "" 32 | echo "=======================================================================" 33 | echo "Build & run Quick Wav-Data Check" 34 | echo "=======================================================================" 35 | 36 | gprbuild -P ./test/quick_wav_data_check/quick_wav_data_check.gpr && \ 37 | ./test/quick_wav_data_check/bin/quick_wav_data_check "$(date +"%Y%m%d-%H%M%S")_" 38 | 39 | echo "" 40 | echo "=======================================================================" 41 | echo "Build & check Cookbook" 42 | echo "=======================================================================" 43 | 44 | ./scripts/test_cookbook.sh 45 | 46 | echo "" 47 | echo "=======================================================================" 48 | echo "Build & run Simple Benchmarking" 49 | echo "=======================================================================" 50 | 51 | gprclean -r -P ./test/simple_benchmarking/simple_benchmarking.gpr && \ 52 | gprbuild -P ./test/simple_benchmarking/simple_benchmarking.gpr \ 53 | -XWAVEFILES_BUILD_MODE=RELEASE && \ 54 | ./scripts/simple_benchmarking.sh 55 | -------------------------------------------------------------------------------- /cookbook/ref/copy_parts_of_wavefile.log: -------------------------------------------------------------------------------- 1 | Writing wavefile at 0.00000000000000000E+00 seconds (at sample # 0) 2 | Starting loop at 9.59791666666666667E-02 seconds (at sample # 4607) 3 | Stopping loop at 1.17104166666666667E-01 seconds (at sample # 5621) 4 | Writing wavefile at 2.11250000000000000E-02 seconds (at sample # 1014) 5 | Starting loop at 9.59791666666666667E-02 seconds (at sample # 4607) 6 | Stopping loop at 1.17104166666666667E-01 seconds (at sample # 5621) 7 | Writing wavefile at 4.22500000000000000E-02 seconds (at sample # 2028) 8 | Starting loop at 9.59791666666666667E-02 seconds (at sample # 4607) 9 | Stopping loop at 1.17104166666666667E-01 seconds (at sample # 5621) 10 | Writing wavefile at 6.33750000000000000E-02 seconds (at sample # 3042) 11 | Starting loop at 9.59791666666666667E-02 seconds (at sample # 4607) 12 | Stopping loop at 1.17104166666666667E-01 seconds (at sample # 5621) 13 | Writing wavefile at 8.45000000000000000E-02 seconds (at sample # 4056) 14 | Starting loop at 9.59791666666666667E-02 seconds (at sample # 4607) 15 | Stopping loop at 1.17104166666666667E-01 seconds (at sample # 5621) 16 | Writing wavefile at 1.05625000000000000E-01 seconds (at sample # 5070) 17 | Starting loop at 9.59791666666666667E-02 seconds (at sample # 4607) 18 | Stopping loop at 1.17104166666666667E-01 seconds (at sample # 5621) 19 | Writing wavefile at 1.26750000000000000E-01 seconds (at sample # 6084) 20 | Starting loop at 9.59791666666666667E-02 seconds (at sample # 4607) 21 | Stopping loop at 1.17104166666666667E-01 seconds (at sample # 5621) 22 | Writing wavefile at 1.47875000000000000E-01 seconds (at sample # 7098) 23 | Starting loop at 9.59791666666666667E-02 seconds (at sample # 4607) 24 | Stopping loop at 1.17104166666666667E-01 seconds (at sample # 5621) 25 | Writing wavefile at 1.69000000000000000E-01 seconds (at sample # 8112) 26 | Starting loop at 9.59791666666666667E-02 seconds (at sample # 4607) 27 | Stopping loop at 1.17104166666666667E-01 seconds (at sample # 5621) 28 | Writing wavefile at 1.90125000000000000E-01 seconds (at sample # 9126) 29 | Starting loop at 9.59791666666666667E-02 seconds (at sample # 4607) 30 | Stopping loop at 1.17104166666666667E-01 seconds (at sample # 5621) 31 | Writing wavefile at 2.11250000000000000E-01 seconds (at sample # 10140) 32 | -------------------------------------------------------------------------------- /src/audio-riff-wav.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- AUDIO / RIFF -- 4 | -- -- 5 | -- Common RIFF information for wavefiles -- 6 | -- -- 7 | -- The MIT License (MIT) -- 8 | -- -- 9 | -- Copyright (c) 2020 Gustavo A. Hoffmann -- 10 | -- -- 11 | -- Permission is hereby granted, free of charge, to any person obtaining -- 12 | -- a copy of this software and associated documentation files (the -- 13 | -- "Software"), to deal in the Software without restriction, including -- 14 | -- without limitation the rights to use, copy, modify, merge, publish, -- 15 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 16 | -- permit persons to whom the Software is furnished to do so, subject to -- 17 | -- the following conditions: -- 18 | -- -- 19 | -- The above copyright notice and this permission notice shall be -- 20 | -- included in all copies or substantial portions of the Software. -- 21 | -- -- 22 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 23 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 24 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 25 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 26 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 27 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 28 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 29 | ------------------------------------------------------------------------------ 30 | 31 | package Audio.RIFF.Wav with Pure is 32 | 33 | end Audio.RIFF.Wav; 34 | -------------------------------------------------------------------------------- /test/quick_wav_data_check/src/quick_wav_data_check.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- WAVEFILES -- 4 | -- -- 5 | -- Quick Wave Data I/O Check -- 6 | -- -- 7 | -- The MIT License (MIT) -- 8 | -- -- 9 | -- Copyright (c) 2020 Gustavo A. Hoffmann -- 10 | -- -- 11 | -- Permission is hereby granted, free of charge, to any person obtaining -- 12 | -- a copy of this software and associated documentation files (the -- 13 | -- "Software"), to deal in the Software without restriction, including -- 14 | -- without limitation the rights to use, copy, modify, merge, publish, -- 15 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 16 | -- permit persons to whom the Software is furnished to do so, subject to -- 17 | -- the following conditions: -- 18 | -- -- 19 | -- The above copyright notice and this permission notice shall be -- 20 | -- included in all copies or substantial portions of the Software. -- 21 | -- -- 22 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 23 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 24 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 25 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 26 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 27 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 28 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 29 | ------------------------------------------------------------------------------ 30 | 31 | function Quick_Wav_Data_Check return Integer; 32 | -------------------------------------------------------------------------------- /test/quick_wav_data_check/src/quick_wav_data_checks.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- WAVEFILES -- 4 | -- -- 5 | -- Quick Wave Data I/O Check -- 6 | -- -- 7 | -- The MIT License (MIT) -- 8 | -- -- 9 | -- Copyright (c) 2020 Gustavo A. Hoffmann -- 10 | -- -- 11 | -- Permission is hereby granted, free of charge, to any person obtaining -- 12 | -- a copy of this software and associated documentation files (the -- 13 | -- "Software"), to deal in the Software without restriction, including -- 14 | -- without limitation the rights to use, copy, modify, merge, publish, -- 15 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 16 | -- permit persons to whom the Software is furnished to do so, subject to -- 17 | -- the following conditions: -- 18 | -- -- 19 | -- The above copyright notice and this permission notice shall be -- 20 | -- included in all copies or substantial portions of the Software. -- 21 | -- -- 22 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 23 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 24 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 25 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 26 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 27 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 28 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 29 | ------------------------------------------------------------------------------ 30 | 31 | package Quick_Wav_Data_Checks is 32 | 33 | function Wav_IO_OK 34 | (Wav_Filename_Prefix : String) return Boolean; 35 | 36 | end Quick_Wav_Data_Checks; 37 | -------------------------------------------------------------------------------- /test/quick_wav_data_check/quick_wav_data_check.gpr: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | -- 3 | -- WAVEFILES 4 | -- 5 | -- Quick Wave Data I/O Check 6 | -- 7 | -- The MIT License (MIT) 8 | -- 9 | -- Copyright (c) 2020 Gustavo A. Hoffmann 10 | -- 11 | -- Permission is hereby granted, free of charge, to any person obtaining a 12 | -- copy of this software and associated documentation files (the "Software"), 13 | -- to deal in the Software without restriction, including without limitation 14 | -- the rights to use, copy, modify, merge, publish, distribute, sublicense, 15 | -- and / or sell copies of the Software, and to permit persons to whom the 16 | -- Software is furnished to do so, subject to the following conditions: 17 | -- 18 | -- The above copyright notice and this permission notice shall be included in 19 | -- all copies or substantial portions of the Software. 20 | -- 21 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 27 | -- DEALINGS IN THE SOFTWARE. 28 | ------------------------------------------------------------------------------- 29 | 30 | with "audio_wavefiles.gpr"; 31 | 32 | project Quick_Wav_Data_Check is 33 | 34 | for Source_Dirs use ("src/**"); 35 | for Object_Dir use "./obj"; 36 | for Exec_Dir use "./bin"; 37 | for Create_Missing_Dirs use "True"; 38 | 39 | for Main use ("quick_wav_data_check.adb"); 40 | 41 | package Ide is 42 | for Vcs_Kind use "git"; 43 | for Documentation_Dir use "./doc"; 44 | end Ide; 45 | 46 | package Compiler is 47 | for Default_Switches ("ada") use ("-gnata", "-gnato", "-gnatVa", "-gnatwa", "-fstack-check", "-gnaty3ACIM79Oabcdefhiklnprstux", "-g", "-gnatQ"); 48 | end Compiler; 49 | 50 | package Linker is 51 | for Default_Switches ("ada") use ("-g"); 52 | end Linker; 53 | 54 | package Builder is 55 | for Default_Switches ("ada") use ("-g", "-s"); 56 | end Builder; 57 | 58 | package Pretty_Printer is 59 | for Default_Switches ("ada") use ("-A0", "-A1", "-A2", "-A3", "-A4", "-A5", "-c4", "-c3", "--separate-loop-then"); 60 | end Pretty_Printer; 61 | 62 | end Quick_Wav_Data_Check; 63 | -------------------------------------------------------------------------------- /src/audio-wavefiles-write.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- WAVEFILES -- 4 | -- -- 5 | -- Wavefile writing routines -- 6 | -- -- 7 | -- The MIT License (MIT) -- 8 | -- -- 9 | -- Copyright (c) 2015 -- 2020 Gustavo A. Hoffmann -- 10 | -- -- 11 | -- Permission is hereby granted, free of charge, to any person obtaining -- 12 | -- a copy of this software and associated documentation files (the -- 13 | -- "Software"), to deal in the Software without restriction, including -- 14 | -- without limitation the rights to use, copy, modify, merge, publish, -- 15 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 16 | -- permit persons to whom the Software is furnished to do so, subject to -- 17 | -- the following conditions: -- 18 | -- -- 19 | -- The above copyright notice and this permission notice shall be -- 20 | -- included in all copies or substantial portions of the Software. -- 21 | -- -- 22 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 23 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 24 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 25 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 26 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 27 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 28 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 29 | ------------------------------------------------------------------------------ 30 | 31 | private package Audio.Wavefiles.Write is 32 | 33 | procedure Write_Until_Data_Start 34 | (WF : in out Wavefile); 35 | 36 | procedure Update_Data_Size 37 | (WF : in out Wavefile); 38 | 39 | end Audio.Wavefiles.Write; 40 | -------------------------------------------------------------------------------- /src/audio-riff-wav-formats-report.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- AUDIO / RIFF / WAV -- 4 | -- -- 5 | -- Reporting of RIFF format information for wavefiles -- 6 | -- -- 7 | -- The MIT License (MIT) -- 8 | -- -- 9 | -- Copyright (c) 2015 -- 2020 Gustavo A. Hoffmann -- 10 | -- -- 11 | -- Permission is hereby granted, free of charge, to any person obtaining -- 12 | -- a copy of this software and associated documentation files (the -- 13 | -- "Software"), to deal in the Software without restriction, including -- 14 | -- without limitation the rights to use, copy, modify, merge, publish, -- 15 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 16 | -- permit persons to whom the Software is furnished to do so, subject to -- 17 | -- the following conditions: -- 18 | -- -- 19 | -- The above copyright notice and this permission notice shall be -- 20 | -- included in all copies or substantial portions of the Software. -- 21 | -- -- 22 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 23 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 24 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 25 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 26 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 27 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 28 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 29 | ------------------------------------------------------------------------------ 30 | 31 | package Audio.RIFF.Wav.Formats.Report is 32 | 33 | procedure Print (W : Wave_Format_Extensible); 34 | 35 | function Image (B : Wav_Bit_Depth) return String is 36 | (Positive'Image (To_Positive (B))); 37 | 38 | end Audio.RIFF.Wav.Formats.Report; 39 | -------------------------------------------------------------------------------- /src/audio-wavefiles-report.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- WAVEFILES -- 4 | -- -- 5 | -- Wavefile reporting routines -- 6 | -- -- 7 | -- The MIT License (MIT) -- 8 | -- -- 9 | -- Copyright (c) 2015 -- 2020 Gustavo A. Hoffmann -- 10 | -- -- 11 | -- Permission is hereby granted, free of charge, to any person obtaining -- 12 | -- a copy of this software and associated documentation files (the -- 13 | -- "Software"), to deal in the Software without restriction, including -- 14 | -- without limitation the rights to use, copy, modify, merge, publish, -- 15 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 16 | -- permit persons to whom the Software is furnished to do so, subject to -- 17 | -- the following conditions: -- 18 | -- -- 19 | -- The above copyright notice and this permission notice shall be -- 20 | -- included in all copies or substantial portions of the Software. -- 21 | -- -- 22 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 23 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 24 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 25 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 26 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 27 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 28 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 29 | ------------------------------------------------------------------------------ 30 | 31 | package Audio.Wavefiles.Report is 32 | 33 | procedure Display_Info (WF : Wavefile) 34 | with Pre => Mode (WF) = In_File; 35 | 36 | procedure Display_Info (RIFF_Info : RIFF_Information); 37 | 38 | procedure Display_Errors (WF : Wavefile); 39 | 40 | procedure Display_Warnings (WF : Wavefile); 41 | 42 | end Audio.Wavefiles.Report; 43 | -------------------------------------------------------------------------------- /src/audio-wavefiles-read.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- WAVEFILES -- 4 | -- -- 5 | -- Wavefile reading routines -- 6 | -- -- 7 | -- The MIT License (MIT) -- 8 | -- -- 9 | -- Copyright (c) 2015 -- 2020 Gustavo A. Hoffmann -- 10 | -- -- 11 | -- Permission is hereby granted, free of charge, to any person obtaining -- 12 | -- a copy of this software and associated documentation files (the -- 13 | -- "Software"), to deal in the Software without restriction, including -- 14 | -- without limitation the rights to use, copy, modify, merge, publish, -- 15 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 16 | -- permit persons to whom the Software is furnished to do so, subject to -- 17 | -- the following conditions: -- 18 | -- -- 19 | -- The above copyright notice and this permission notice shall be -- 20 | -- included in all copies or substantial portions of the Software. -- 21 | -- -- 22 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 23 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 24 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 25 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 26 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 27 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 28 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 29 | ------------------------------------------------------------------------------ 30 | 31 | private package Audio.Wavefiles.Read is 32 | 33 | procedure Read_Until_Data_Start 34 | (WF : in out Wavefile); 35 | 36 | procedure Parse_Wav_Chunks 37 | (WF : in out Wavefile); 38 | 39 | procedure Set_Current_Sample 40 | (WF : in out Wavefile; 41 | Position : Sample_Count); 42 | 43 | end Audio.Wavefiles.Read; 44 | -------------------------------------------------------------------------------- /test/quick_wav_data_check/src/quick_wav_data_checks-fixed_checks.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! -- 4 | -- -- 5 | -- WAVEFILES -- 6 | -- -- 7 | -- Quick Wave Data I/O Check -- 8 | -- -- 9 | -- The MIT License (MIT) -- 10 | -- -- 11 | -- Copyright (c) 2020 Gustavo A. Hoffmann -- 12 | -- -- 13 | -- Permission is hereby granted, free of charge, to any person obtaining -- 14 | -- a copy of this software and associated documentation files (the -- 15 | -- "Software"), to deal in the Software without restriction, including -- 16 | -- without limitation the rights to use, copy, modify, merge, publish, -- 17 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 18 | -- permit persons to whom the Software is furnished to do so, subject to -- 19 | -- the following conditions: -- 20 | -- -- 21 | -- The above copyright notice and this permission notice shall be -- 22 | -- included in all copies or substantial portions of the Software. -- 23 | -- -- 24 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 25 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 26 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 27 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 28 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 29 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 30 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 31 | ------------------------------------------------------------------------------ 32 | 33 | package Quick_Wav_Data_Checks.Fixed_Checks is 34 | 35 | function Wav_IO_OK 36 | (Wav_Filename_Prefix : String) return Boolean; 37 | 38 | end Quick_Wav_Data_Checks.Fixed_Checks; 39 | -------------------------------------------------------------------------------- /test/quick_wav_data_check/src/quick_wav_data_checks-float_checks.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! -- 4 | -- -- 5 | -- WAVEFILES -- 6 | -- -- 7 | -- Quick Wave Data I/O Check -- 8 | -- -- 9 | -- The MIT License (MIT) -- 10 | -- -- 11 | -- Copyright (c) 2020 Gustavo A. Hoffmann -- 12 | -- -- 13 | -- Permission is hereby granted, free of charge, to any person obtaining -- 14 | -- a copy of this software and associated documentation files (the -- 15 | -- "Software"), to deal in the Software without restriction, including -- 16 | -- without limitation the rights to use, copy, modify, merge, publish, -- 17 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 18 | -- permit persons to whom the Software is furnished to do so, subject to -- 19 | -- the following conditions: -- 20 | -- -- 21 | -- The above copyright notice and this permission notice shall be -- 22 | -- included in all copies or substantial portions of the Software. -- 23 | -- -- 24 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 25 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 26 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 27 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 28 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 29 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 30 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 31 | ------------------------------------------------------------------------------ 32 | 33 | package Quick_Wav_Data_Checks.Float_Checks is 34 | 35 | function Wav_IO_OK 36 | (Wav_Filename_Prefix : String) return Boolean; 37 | 38 | end Quick_Wav_Data_Checks.Float_Checks; 39 | -------------------------------------------------------------------------------- /test/quick_wav_data_check/src/quick_wav_data_check.adb: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- WAVEFILES -- 4 | -- -- 5 | -- Quick Wave Data I/O Check -- 6 | -- -- 7 | -- The MIT License (MIT) -- 8 | -- -- 9 | -- Copyright (c) 2020 Gustavo A. Hoffmann -- 10 | -- -- 11 | -- Permission is hereby granted, free of charge, to any person obtaining -- 12 | -- a copy of this software and associated documentation files (the -- 13 | -- "Software"), to deal in the Software without restriction, including -- 14 | -- without limitation the rights to use, copy, modify, merge, publish, -- 15 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 16 | -- permit persons to whom the Software is furnished to do so, subject to -- 17 | -- the following conditions: -- 18 | -- -- 19 | -- The above copyright notice and this permission notice shall be -- 20 | -- included in all copies or substantial portions of the Software. -- 21 | -- -- 22 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 23 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 24 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 25 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 26 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 27 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 28 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 29 | ------------------------------------------------------------------------------ 30 | 31 | with Ada.Command_Line; use Ada.Command_Line; 32 | 33 | with Quick_Wav_Data_Checks; use Quick_Wav_Data_Checks; 34 | 35 | function Quick_Wav_Data_Check return Integer is 36 | Success : Boolean; 37 | begin 38 | if Argument_Count >= 1 then 39 | Success := Wav_IO_OK (Argument (1)); 40 | else 41 | Success := Wav_IO_OK ("quick_"); 42 | end if; 43 | 44 | if Success then 45 | return 0; 46 | else 47 | return 1; 48 | end if; 49 | end Quick_Wav_Data_Check; 50 | -------------------------------------------------------------------------------- /test/simple_benchmarking/src/wavefile_benchmarking-statistics.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- WAVEFILES -- 4 | -- -- 5 | -- Wavefile benchmarking -- 6 | -- -- 7 | -- The MIT License (MIT) -- 8 | -- -- 9 | -- Copyright (c) 2020 Gustavo A. Hoffmann -- 10 | -- -- 11 | -- Permission is hereby granted, free of charge, to any person obtaining -- 12 | -- a copy of this software and associated documentation files (the -- 13 | -- "Software"), to deal in the Software without restriction, including -- 14 | -- without limitation the rights to use, copy, modify, merge, publish, -- 15 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 16 | -- permit persons to whom the Software is furnished to do so, subject to -- 17 | -- the following conditions: -- 18 | -- -- 19 | -- The above copyright notice and this permission notice shall be -- 20 | -- included in all copies or substantial portions of the Software. -- 21 | -- -- 22 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 23 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 24 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 25 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 26 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 27 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 28 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 29 | ------------------------------------------------------------------------------ 30 | 31 | package Wavefile_Benchmarking.Statistics is 32 | 33 | type Wavefile_Benchmark_Statistics is record 34 | Max : Wavefile_Benchmark_kHz := (Float'First, Float'First); 35 | Min : Wavefile_Benchmark_kHz := (Float'Last, Float'Last); 36 | Avg : Wavefile_Benchmark_kHz := (0.0, 0.0); 37 | end record; 38 | 39 | procedure Calculate_Statistics 40 | (Raw_Info : Wavefile_Benchmark_Infos; 41 | Results : out Wavefile_Benchmark_Statistics); 42 | 43 | procedure Display (Stats : Wavefile_Benchmark_Statistics); 44 | 45 | end Wavefile_Benchmarking.Statistics; 46 | -------------------------------------------------------------------------------- /test/simple_benchmarking/src/time_span_conversions.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- WAVEFILES -- 4 | -- -- 5 | -- Wavefile benchmarking -- 6 | -- -- 7 | -- The MIT License (MIT) -- 8 | -- -- 9 | -- Copyright (c) 2020 Gustavo A. Hoffmann -- 10 | -- -- 11 | -- Permission is hereby granted, free of charge, to any person obtaining -- 12 | -- a copy of this software and associated documentation files (the -- 13 | -- "Software"), to deal in the Software without restriction, including -- 14 | -- without limitation the rights to use, copy, modify, merge, publish, -- 15 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 16 | -- permit persons to whom the Software is furnished to do so, subject to -- 17 | -- the following conditions: -- 18 | -- -- 19 | -- The above copyright notice and this permission notice shall be -- 20 | -- included in all copies or substantial portions of the Software. -- 21 | -- -- 22 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 23 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 24 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 25 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 26 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 27 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 28 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 29 | ------------------------------------------------------------------------------ 30 | 31 | with Ada.Real_Time; use Ada.Real_Time; 32 | 33 | package Time_Span_Conversions is 34 | 35 | function To_MHz (Elapsed_Time : Time_Span; 36 | CPU_MHz : Float; 37 | Factor : Long_Long_Float) return Float; 38 | 39 | function To_kHz (Elapsed_Time : Time_Span; 40 | CPU_MHz : Float; 41 | Factor : Long_Long_Float) return Float; 42 | 43 | function To_Miliseconds (Elapsed_Time : Time_Span) return Float; 44 | 45 | function To_Nanoseconds (Elapsed_Time : Time_Span) return Float; 46 | 47 | end Time_Span_Conversions; 48 | -------------------------------------------------------------------------------- /test/quick_wav_data_check/src.prep/quick_wav_data_checks-NUM_TYPE_checks.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! -- 4 | -- -- 5 | -- WAVEFILES -- 6 | -- -- 7 | -- Quick Wave Data I/O Check -- 8 | -- -- 9 | -- The MIT License (MIT) -- 10 | -- -- 11 | -- Copyright (c) 2020 Gustavo A. Hoffmann -- 12 | -- -- 13 | -- Permission is hereby granted, free of charge, to any person obtaining -- 14 | -- a copy of this software and associated documentation files (the -- 15 | -- "Software"), to deal in the Software without restriction, including -- 16 | -- without limitation the rights to use, copy, modify, merge, publish, -- 17 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 18 | -- permit persons to whom the Software is furnished to do so, subject to -- 19 | -- the following conditions: -- 20 | -- -- 21 | -- The above copyright notice and this permission notice shall be -- 22 | -- included in all copies or substantial portions of the Software. -- 23 | -- -- 24 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 25 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 26 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 27 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 28 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 29 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 30 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 31 | ------------------------------------------------------------------------------ 32 | 33 | #if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then 34 | package Quick_Wav_Data_Checks.Float_Checks is 35 | #else 36 | package Quick_Wav_Data_Checks.Fixed_Checks is 37 | #end if; 38 | 39 | function Wav_IO_OK 40 | (Wav_Filename_Prefix : String) return Boolean; 41 | 42 | #if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then 43 | end Quick_Wav_Data_Checks.Float_Checks; 44 | #else 45 | end Quick_Wav_Data_Checks.Fixed_Checks; 46 | #end if; 47 | -------------------------------------------------------------------------------- /test/simple_benchmarking/src/wavefile_benchmarking.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- WAVEFILES -- 4 | -- -- 5 | -- Wavefile benchmarking -- 6 | -- -- 7 | -- The MIT License (MIT) -- 8 | -- -- 9 | -- Copyright (c) 2020 Gustavo A. Hoffmann -- 10 | -- -- 11 | -- Permission is hereby granted, free of charge, to any person obtaining -- 12 | -- a copy of this software and associated documentation files (the -- 13 | -- "Software"), to deal in the Software without restriction, including -- 14 | -- without limitation the rights to use, copy, modify, merge, publish, -- 15 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 16 | -- permit persons to whom the Software is furnished to do so, subject to -- 17 | -- the following conditions: -- 18 | -- -- 19 | -- The above copyright notice and this permission notice shall be -- 20 | -- included in all copies or substantial portions of the Software. -- 21 | -- -- 22 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 23 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 24 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 25 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 26 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 27 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 28 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 29 | ------------------------------------------------------------------------------ 30 | 31 | package Wavefile_Benchmarking is 32 | 33 | type Wavefile_Benchmark_Routine is (Wavefile_Read_Benchmark, 34 | Wavefile_Write_Benchmark); 35 | 36 | type Wavefile_Benchmark_kHz is 37 | array (Wavefile_Benchmark_Routine'Range) of Float; 38 | 39 | type Wavefile_Benchmark_Infos is array (Positive range <>) of 40 | Wavefile_Benchmark_kHz; 41 | 42 | function Benchm_CPU_Time (CPU_MHz : Float) return Wavefile_Benchmark_kHz; 43 | 44 | procedure Benchm_CPU_Time (CPU_MHz : Float; 45 | Results : out Wavefile_Benchmark_Infos); 46 | 47 | end Wavefile_Benchmarking; 48 | -------------------------------------------------------------------------------- /test/wavefiles_test/src/generic_fixed_pcm_buffer_ops.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! -- 4 | -- -- 5 | -- WAVEFILES -- 6 | -- -- 7 | -- Test application -- 8 | -- -- 9 | -- The MIT License (MIT) -- 10 | -- -- 11 | -- Copyright (c) 2020 Gustavo A. Hoffmann -- 12 | -- -- 13 | -- Permission is hereby granted, free of charge, to any person obtaining -- 14 | -- a copy of this software and associated documentation files (the -- 15 | -- "Software"), to deal in the Software without restriction, including -- 16 | -- without limitation the rights to use, copy, modify, merge, publish, -- 17 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 18 | -- permit persons to whom the Software is furnished to do so, subject to -- 19 | -- the following conditions: -- 20 | -- -- 21 | -- The above copyright notice and this permission notice shall be -- 22 | -- included in all copies or substantial portions of the Software. -- 23 | -- -- 24 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 25 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 26 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 27 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 28 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 29 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 30 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 31 | ------------------------------------------------------------------------------ 32 | 33 | generic 34 | type PCM_Sample is delta <>; 35 | type PCM_MC_Sample is array (Positive range <>) of PCM_Sample; 36 | package Generic_Fixed_PCM_Buffer_Ops is 37 | 38 | function "+" (PCM_Ref : PCM_MC_Sample; 39 | PCM_DUT : PCM_MC_Sample) 40 | return PCM_MC_Sample; 41 | 42 | function "-" (PCM_Ref : PCM_MC_Sample; 43 | PCM_DUT : PCM_MC_Sample) 44 | return PCM_MC_Sample; 45 | 46 | end Generic_Fixed_PCM_Buffer_Ops; 47 | -------------------------------------------------------------------------------- /test/wavefiles_test/src/generic_float_pcm_buffer_ops.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! -- 4 | -- -- 5 | -- WAVEFILES -- 6 | -- -- 7 | -- Test application -- 8 | -- -- 9 | -- The MIT License (MIT) -- 10 | -- -- 11 | -- Copyright (c) 2020 Gustavo A. Hoffmann -- 12 | -- -- 13 | -- Permission is hereby granted, free of charge, to any person obtaining -- 14 | -- a copy of this software and associated documentation files (the -- 15 | -- "Software"), to deal in the Software without restriction, including -- 16 | -- without limitation the rights to use, copy, modify, merge, publish, -- 17 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 18 | -- permit persons to whom the Software is furnished to do so, subject to -- 19 | -- the following conditions: -- 20 | -- -- 21 | -- The above copyright notice and this permission notice shall be -- 22 | -- included in all copies or substantial portions of the Software. -- 23 | -- -- 24 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 25 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 26 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 27 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 28 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 29 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 30 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 31 | ------------------------------------------------------------------------------ 32 | 33 | generic 34 | type PCM_Sample is digits <>; 35 | type PCM_MC_Sample is array (Positive range <>) of PCM_Sample; 36 | package Generic_Float_PCM_Buffer_Ops is 37 | 38 | function "+" (PCM_Ref : PCM_MC_Sample; 39 | PCM_DUT : PCM_MC_Sample) 40 | return PCM_MC_Sample; 41 | 42 | function "-" (PCM_Ref : PCM_MC_Sample; 43 | PCM_DUT : PCM_MC_Sample) 44 | return PCM_MC_Sample; 45 | 46 | end Generic_Float_PCM_Buffer_Ops; 47 | -------------------------------------------------------------------------------- /test/quick_wav_data_check/src/quick_wav_data_checks.adb: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- WAVEFILES -- 4 | -- -- 5 | -- Quick Wave Data I/O Check -- 6 | -- -- 7 | -- The MIT License (MIT) -- 8 | -- -- 9 | -- Copyright (c) 2020 Gustavo A. Hoffmann -- 10 | -- -- 11 | -- Permission is hereby granted, free of charge, to any person obtaining -- 12 | -- a copy of this software and associated documentation files (the -- 13 | -- "Software"), to deal in the Software without restriction, including -- 14 | -- without limitation the rights to use, copy, modify, merge, publish, -- 15 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 16 | -- permit persons to whom the Software is furnished to do so, subject to -- 17 | -- the following conditions: -- 18 | -- -- 19 | -- The above copyright notice and this permission notice shall be -- 20 | -- included in all copies or substantial portions of the Software. -- 21 | -- -- 22 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 23 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 24 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 25 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 26 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 27 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 28 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 29 | ------------------------------------------------------------------------------ 30 | 31 | with Quick_Wav_Data_Checks.Float_Checks; 32 | with Quick_Wav_Data_Checks.Fixed_Checks; 33 | 34 | package body Quick_Wav_Data_Checks is 35 | 36 | --------------- 37 | -- Wav_IO_OK -- 38 | --------------- 39 | 40 | function Wav_IO_OK 41 | (Wav_Filename_Prefix : String) return Boolean 42 | is 43 | Success : Boolean := True; 44 | begin 45 | if not Fixed_Checks.Wav_IO_OK (Wav_Filename_Prefix) then 46 | Success := False; 47 | end if; 48 | if not Float_Checks.Wav_IO_OK (Wav_Filename_Prefix) then 49 | Success := False; 50 | end if; 51 | 52 | return Success; 53 | end Wav_IO_OK; 54 | 55 | end Quick_Wav_Data_Checks; 56 | -------------------------------------------------------------------------------- /scripts/generate_src.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 4 | 5 | TEST_EXIT_CODE=0 6 | 7 | function generate_src_file { 8 | SRC=$1 9 | NUM_TYPE=$2 10 | NUM_TYPE_2=$3 11 | TARGET_SRC=$(echo $SRC | sed -e 's#\.prep##' \ 12 | | sed -e "s#NUM_TYPE_2#${NUM_TYPE_2}#" \ 13 | | sed -e "s#NUM_TYPE#${NUM_TYPE}#") 14 | TEST_SRC=$( echo $SRC | sed -e 's#\.prep##' \ 15 | | sed -e "s#NUM_TYPE_2#${NUM_TYPE_2}#" \ 16 | | sed -e "s#NUM_TYPE#${NUM_TYPE}_TEST#") 17 | 18 | if [ "$TEST" == "1" ] 19 | then 20 | OUTPUT_SRC=$TEST_SRC 21 | else 22 | OUTPUT_SRC=$TARGET_SRC 23 | fi 24 | 25 | if [ "$NUM_TYPE_2" != "" ] 26 | then 27 | gnatprep -DNUM_TYPE=${NUM_TYPE} -DNUM_TYPE_2=${NUM_TYPE_2} $SRC $OUTPUT_SRC 28 | else 29 | gnatprep -DNUM_TYPE=${NUM_TYPE} $SRC $OUTPUT_SRC 30 | fi 31 | 32 | if [ "$TEST" == "1" ] 33 | then 34 | diff $TARGET_SRC $TEST_SRC 35 | if [ "$?" -ne "0" ] 36 | then 37 | echo "ERROR: differences detected in file $TARGET_SRC" 38 | TEST_EXIT_CODE=1 39 | else 40 | echo "PASS: $TARGET_SRC" 41 | fi 42 | 43 | rm -f $TEST_SRC 44 | fi 45 | } 46 | 47 | function generate_src_2_files { 48 | SRC=$1 49 | for num_type_1 in float fixed 50 | do 51 | generate_src_file $SRC $num_type_1 52 | done 53 | } 54 | 55 | function generate_src_4_files { 56 | SRC=$1 57 | for num_type_1 in float fixed 58 | do 59 | for num_type_2 in float fixed 60 | do 61 | generate_src_file $SRC $num_type_1 $num_type_2 62 | done 63 | done 64 | } 65 | 66 | generate_src_4_files $DIR/../src.prep/audio-wavefiles-generic_NUM_TYPE_wav_NUM_TYPE_2_pcm_io.ads 67 | generate_src_4_files $DIR/../src.prep/audio-wavefiles-generic_NUM_TYPE_wav_NUM_TYPE_2_pcm_io.adb 68 | 69 | generate_src_2_files $DIR/../src.prep/audio-wavefiles-generic_NUM_TYPE_wav_io.ads 70 | generate_src_2_files $DIR/../src.prep/audio-wavefiles-generic_NUM_TYPE_wav_io.adb 71 | 72 | generate_src_2_files $DIR/../src.prep/audio-wavefiles-generic_NUM_TYPE_pcm_io.ads 73 | generate_src_2_files $DIR/../src.prep/audio-wavefiles-generic_NUM_TYPE_pcm_io.adb 74 | 75 | generate_src_2_files $DIR/../src.prep/audio-wavefiles-generic_direct_NUM_TYPE_wav_io.ads 76 | generate_src_2_files $DIR/../src.prep/audio-wavefiles-generic_direct_NUM_TYPE_wav_io.adb 77 | 78 | generate_src_2_files $DIR/../test/wavefiles_test/src.prep/generic_NUM_TYPE_pcm_buffer_ops.adb 79 | generate_src_2_files $DIR/../test/wavefiles_test/src.prep/generic_NUM_TYPE_pcm_buffer_ops.ads 80 | generate_src_2_files $DIR/../test/wavefiles_test/src.prep/generic_NUM_TYPE_wave_test.adb 81 | generate_src_2_files $DIR/../test/wavefiles_test/src.prep/generic_NUM_TYPE_wave_test.ads 82 | 83 | generate_src_2_files $DIR/../test/quick_wav_data_check/src.prep/quick_wav_data_checks-NUM_TYPE_checks.ads 84 | generate_src_2_files $DIR/../test/quick_wav_data_check/src.prep/quick_wav_data_checks-NUM_TYPE_checks.adb 85 | 86 | exit $TEST_EXIT_CODE 87 | -------------------------------------------------------------------------------- /src/audio-wavefiles-generic_fixed_pcm_io.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! -- 4 | -- -- 5 | -- WAVEFILES -- 6 | -- -- 7 | -- Wavefile I/O operations for PCM buffers -- 8 | -- -- 9 | -- The MIT License (MIT) -- 10 | -- -- 11 | -- Copyright (c) 2015 -- 2020 Gustavo A. Hoffmann -- 12 | -- -- 13 | -- Permission is hereby granted, free of charge, to any person obtaining -- 14 | -- a copy of this software and associated documentation files (the -- 15 | -- "Software"), to deal in the Software without restriction, including -- 16 | -- without limitation the rights to use, copy, modify, merge, publish, -- 17 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 18 | -- permit persons to whom the Software is furnished to do so, subject to -- 19 | -- the following conditions: -- 20 | -- -- 21 | -- The above copyright notice and this permission notice shall be -- 22 | -- included in all copies or substantial portions of the Software. -- 23 | -- -- 24 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 25 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 26 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 27 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 28 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 29 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 30 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 31 | ------------------------------------------------------------------------------ 32 | 33 | generic 34 | type PCM_Sample is delta <>; 35 | type Channel_Range is (<>); 36 | type PCM_MC_Sample is array (Channel_Range range <>) of PCM_Sample; 37 | package Audio.Wavefiles.Generic_Fixed_PCM_IO is 38 | 39 | function Get 40 | (WF : in out Wavefile) return PCM_MC_Sample 41 | with Inline, Pre => Mode (WF) = In_File; 42 | 43 | procedure Get 44 | (WF : in out Wavefile; 45 | PCM : out PCM_MC_Sample) 46 | with Inline, Pre => Mode (WF) = In_File; 47 | 48 | procedure Put 49 | (WF : in out Wavefile; 50 | PCM : PCM_MC_Sample) 51 | with Pre => Mode (WF) = Out_File; 52 | 53 | end Audio.Wavefiles.Generic_Fixed_PCM_IO; 54 | -------------------------------------------------------------------------------- /src/audio-wavefiles-generic_float_pcm_io.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! -- 4 | -- -- 5 | -- WAVEFILES -- 6 | -- -- 7 | -- Wavefile I/O operations for PCM buffers -- 8 | -- -- 9 | -- The MIT License (MIT) -- 10 | -- -- 11 | -- Copyright (c) 2015 -- 2020 Gustavo A. Hoffmann -- 12 | -- -- 13 | -- Permission is hereby granted, free of charge, to any person obtaining -- 14 | -- a copy of this software and associated documentation files (the -- 15 | -- "Software"), to deal in the Software without restriction, including -- 16 | -- without limitation the rights to use, copy, modify, merge, publish, -- 17 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 18 | -- permit persons to whom the Software is furnished to do so, subject to -- 19 | -- the following conditions: -- 20 | -- -- 21 | -- The above copyright notice and this permission notice shall be -- 22 | -- included in all copies or substantial portions of the Software. -- 23 | -- -- 24 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 25 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 26 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 27 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 28 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 29 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 30 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 31 | ------------------------------------------------------------------------------ 32 | 33 | generic 34 | type PCM_Sample is digits <>; 35 | type Channel_Range is (<>); 36 | type PCM_MC_Sample is array (Channel_Range range <>) of PCM_Sample; 37 | package Audio.Wavefiles.Generic_Float_PCM_IO is 38 | 39 | function Get 40 | (WF : in out Wavefile) return PCM_MC_Sample 41 | with Inline, Pre => Mode (WF) = In_File; 42 | 43 | procedure Get 44 | (WF : in out Wavefile; 45 | PCM : out PCM_MC_Sample) 46 | with Inline, Pre => Mode (WF) = In_File; 47 | 48 | procedure Put 49 | (WF : in out Wavefile; 50 | PCM : PCM_MC_Sample) 51 | with Pre => Mode (WF) = Out_File; 52 | 53 | end Audio.Wavefiles.Generic_Float_PCM_IO; 54 | -------------------------------------------------------------------------------- /src/audio-wavefiles-data_types-text_io.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- WAVEFILES -- 4 | -- -- 5 | -- Text I/O packages for common data types for wavefile buffer I/O -- 6 | -- -- 7 | -- The MIT License (MIT) -- 8 | -- -- 9 | -- Copyright (c) 2020 Gustavo A. Hoffmann -- 10 | -- -- 11 | -- Permission is hereby granted, free of charge, to any person obtaining -- 12 | -- a copy of this software and associated documentation files (the -- 13 | -- "Software"), to deal in the Software without restriction, including -- 14 | -- without limitation the rights to use, copy, modify, merge, publish, -- 15 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 16 | -- permit persons to whom the Software is furnished to do so, subject to -- 17 | -- the following conditions: -- 18 | -- -- 19 | -- The above copyright notice and this permission notice shall be -- 20 | -- included in all copies or substantial portions of the Software. -- 21 | -- -- 22 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 23 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 24 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 25 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 26 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 27 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 28 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 29 | ------------------------------------------------------------------------------ 30 | 31 | with Ada.Text_IO; 32 | 33 | package Audio.Wavefiles.Data_Types.Text_IO is 34 | 35 | package Wav_Fixed_8_Text_IO is new 36 | Ada.Text_IO.Fixed_IO (Wav_Fixed_8); 37 | 38 | package Wav_Fixed_16_Text_IO is new 39 | Ada.Text_IO.Fixed_IO (Wav_Fixed_16); 40 | 41 | package Wav_Fixed_24_Text_IO is new 42 | Ada.Text_IO.Fixed_IO (Wav_Fixed_24); 43 | 44 | package Wav_Fixed_32_Text_IO is new 45 | Ada.Text_IO.Fixed_IO (Wav_Fixed_32); 46 | 47 | package Wav_Fixed_64_Text_IO is new 48 | Ada.Text_IO.Fixed_IO (Wav_Fixed_64); 49 | 50 | package Wav_Float_32_Text_IO is new 51 | Ada.Text_IO.Float_IO (Wav_Float_32); 52 | 53 | package Wav_Float_64_Text_IO is new 54 | Ada.Text_IO.Float_IO (Wav_Float_64); 55 | 56 | package Wav_Float_128_Text_IO is new 57 | Ada.Text_IO.Float_IO (Wav_Float_128); 58 | 59 | end Audio.Wavefiles.Data_Types.Text_IO; 60 | -------------------------------------------------------------------------------- /test/wavefiles_test/src/wave_test_instances.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- WAVEFILES -- 4 | -- -- 5 | -- Test application -- 6 | -- -- 7 | -- The MIT License (MIT) -- 8 | -- -- 9 | -- Copyright (c) 2020 Gustavo A. Hoffmann -- 10 | -- -- 11 | -- Permission is hereby granted, free of charge, to any person obtaining -- 12 | -- a copy of this software and associated documentation files (the -- 13 | -- "Software"), to deal in the Software without restriction, including -- 14 | -- without limitation the rights to use, copy, modify, merge, publish, -- 15 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 16 | -- permit persons to whom the Software is furnished to do so, subject to -- 17 | -- the following conditions: -- 18 | -- -- 19 | -- The above copyright notice and this permission notice shall be -- 20 | -- included in all copies or substantial portions of the Software. -- 21 | -- -- 22 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 23 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 24 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 25 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 26 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 27 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 28 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 29 | ------------------------------------------------------------------------------ 30 | 31 | package Wave_Test_Instances is 32 | 33 | procedure Display_Info_File (File_In : String); 34 | 35 | procedure Copy_File 36 | (File_In : String; 37 | File_Out : String); 38 | 39 | procedure Compare_Files 40 | (File_Ref : String; 41 | File_DUT : String); 42 | 43 | procedure Diff_Files 44 | (File_Ref : String; 45 | File_DUT : String; 46 | File_Diff : String); 47 | 48 | procedure Mix_Files 49 | (File_Ref : String; 50 | File_DUT : String; 51 | File_Mix : String); 52 | 53 | procedure Set_Test_Procedures (Bits : Positive; 54 | Fixed : Boolean; 55 | Status : out Boolean); 56 | 57 | function Get_Bits return Positive; 58 | 59 | function Is_Fixed return Boolean; 60 | 61 | end Wave_Test_Instances; 62 | -------------------------------------------------------------------------------- /src/audio-wavefiles-generic_fixed_wav_io.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! -- 4 | -- -- 5 | -- WAVEFILES -- 6 | -- -- 7 | -- Wavefile data I/O operations -- 8 | -- -- 9 | -- The MIT License (MIT) -- 10 | -- -- 11 | -- Copyright (c) 2015 -- 2021 Gustavo A. Hoffmann -- 12 | -- -- 13 | -- Permission is hereby granted, free of charge, to any person obtaining -- 14 | -- a copy of this software and associated documentation files (the -- 15 | -- "Software"), to deal in the Software without restriction, including -- 16 | -- without limitation the rights to use, copy, modify, merge, publish, -- 17 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 18 | -- permit persons to whom the Software is furnished to do so, subject to -- 19 | -- the following conditions: -- 20 | -- -- 21 | -- The above copyright notice and this permission notice shall be -- 22 | -- included in all copies or substantial portions of the Software. -- 23 | -- -- 24 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 25 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 26 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 27 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 28 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 29 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 30 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 31 | ------------------------------------------------------------------------------ 32 | 33 | private generic 34 | type Wav_Sample is delta <>; 35 | type Channel_Range is (<>); 36 | type Wav_MC_Sample is array (Channel_Range range <>) of Wav_Sample; 37 | package Audio.Wavefiles.Generic_Fixed_Wav_IO is 38 | 39 | function Get (WF : in out Wavefile) return Wav_MC_Sample 40 | with Inline, Pre => Mode (WF) = In_File; 41 | 42 | procedure Get (WF : in out Wavefile; 43 | Wav : out Wav_MC_Sample) 44 | with Inline, Pre => Mode (WF) = In_File; 45 | 46 | procedure Put (WF : in out Wavefile; 47 | Wav : Wav_MC_Sample) 48 | with Inline, 49 | Pre => Mode (WF) = Out_File 50 | and Wav'Length >= Number_Of_Channels (WF); 51 | 52 | end Audio.Wavefiles.Generic_Fixed_Wav_IO; 53 | -------------------------------------------------------------------------------- /src/audio-wavefiles-generic_float_wav_io.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! -- 4 | -- -- 5 | -- WAVEFILES -- 6 | -- -- 7 | -- Wavefile data I/O operations -- 8 | -- -- 9 | -- The MIT License (MIT) -- 10 | -- -- 11 | -- Copyright (c) 2015 -- 2021 Gustavo A. Hoffmann -- 12 | -- -- 13 | -- Permission is hereby granted, free of charge, to any person obtaining -- 14 | -- a copy of this software and associated documentation files (the -- 15 | -- "Software"), to deal in the Software without restriction, including -- 16 | -- without limitation the rights to use, copy, modify, merge, publish, -- 17 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 18 | -- permit persons to whom the Software is furnished to do so, subject to -- 19 | -- the following conditions: -- 20 | -- -- 21 | -- The above copyright notice and this permission notice shall be -- 22 | -- included in all copies or substantial portions of the Software. -- 23 | -- -- 24 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 25 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 26 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 27 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 28 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 29 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 30 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 31 | ------------------------------------------------------------------------------ 32 | 33 | private generic 34 | type Wav_Sample is digits <>; 35 | type Channel_Range is (<>); 36 | type Wav_MC_Sample is array (Channel_Range range <>) of Wav_Sample; 37 | package Audio.Wavefiles.Generic_Float_Wav_IO is 38 | 39 | function Get (WF : in out Wavefile) return Wav_MC_Sample 40 | with Inline, Pre => Mode (WF) = In_File; 41 | 42 | procedure Get (WF : in out Wavefile; 43 | Wav : out Wav_MC_Sample) 44 | with Inline, Pre => Mode (WF) = In_File; 45 | 46 | procedure Put (WF : in out Wavefile; 47 | Wav : Wav_MC_Sample) 48 | with Inline, 49 | Pre => Mode (WF) = Out_File 50 | and Wav'Length >= Number_Of_Channels (WF); 51 | 52 | end Audio.Wavefiles.Generic_Float_Wav_IO; 53 | -------------------------------------------------------------------------------- /test/wavefiles_test/src/generic_fixed_wave_test.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! -- 4 | -- -- 5 | -- WAVEFILES -- 6 | -- -- 7 | -- Test application -- 8 | -- -- 9 | -- The MIT License (MIT) -- 10 | -- -- 11 | -- Copyright (c) 2015 -- 2020 Gustavo A. Hoffmann -- 12 | -- -- 13 | -- Permission is hereby granted, free of charge, to any person obtaining -- 14 | -- a copy of this software and associated documentation files (the -- 15 | -- "Software"), to deal in the Software without restriction, including -- 16 | -- without limitation the rights to use, copy, modify, merge, publish, -- 17 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 18 | -- permit persons to whom the Software is furnished to do so, subject to -- 19 | -- the following conditions: -- 20 | -- -- 21 | -- The above copyright notice and this permission notice shall be -- 22 | -- included in all copies or substantial portions of the Software. -- 23 | -- -- 24 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 25 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 26 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 27 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 28 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 29 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 30 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 31 | ------------------------------------------------------------------------------ 32 | 33 | generic 34 | type PCM_Sample is delta <>; 35 | type PCM_MC_Sample is array (Positive range <>) of PCM_Sample; 36 | package Generic_Fixed_Wave_Test is 37 | 38 | procedure Display_Info_File 39 | (File_In : String); 40 | 41 | procedure Copy_File 42 | (File_In : String; 43 | File_Out : String); 44 | 45 | procedure Compare_Files 46 | (File_Ref : String; 47 | File_DUT : String); 48 | 49 | procedure Diff_Files 50 | (File_Ref : String; 51 | File_DUT : String; 52 | File_Diff : String); 53 | 54 | procedure Mix_Files 55 | (File_Ref : String; 56 | File_DUT : String; 57 | File_Mix : String); 58 | 59 | end Generic_Fixed_Wave_Test; 60 | -------------------------------------------------------------------------------- /test/wavefiles_test/src/generic_float_wave_test.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! -- 4 | -- -- 5 | -- WAVEFILES -- 6 | -- -- 7 | -- Test application -- 8 | -- -- 9 | -- The MIT License (MIT) -- 10 | -- -- 11 | -- Copyright (c) 2015 -- 2020 Gustavo A. Hoffmann -- 12 | -- -- 13 | -- Permission is hereby granted, free of charge, to any person obtaining -- 14 | -- a copy of this software and associated documentation files (the -- 15 | -- "Software"), to deal in the Software without restriction, including -- 16 | -- without limitation the rights to use, copy, modify, merge, publish, -- 17 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 18 | -- permit persons to whom the Software is furnished to do so, subject to -- 19 | -- the following conditions: -- 20 | -- -- 21 | -- The above copyright notice and this permission notice shall be -- 22 | -- included in all copies or substantial portions of the Software. -- 23 | -- -- 24 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 25 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 26 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 27 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 28 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 29 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 30 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 31 | ------------------------------------------------------------------------------ 32 | 33 | generic 34 | type PCM_Sample is digits <>; 35 | type PCM_MC_Sample is array (Positive range <>) of PCM_Sample; 36 | package Generic_Float_Wave_Test is 37 | 38 | procedure Display_Info_File 39 | (File_In : String); 40 | 41 | procedure Copy_File 42 | (File_In : String; 43 | File_Out : String); 44 | 45 | procedure Compare_Files 46 | (File_Ref : String; 47 | File_DUT : String); 48 | 49 | procedure Diff_Files 50 | (File_Ref : String; 51 | File_DUT : String; 52 | File_Diff : String); 53 | 54 | procedure Mix_Files 55 | (File_Ref : String; 56 | File_DUT : String; 57 | File_Mix : String); 58 | 59 | end Generic_Float_Wave_Test; 60 | -------------------------------------------------------------------------------- /src/audio-wavefiles-internals.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- WAVEFILES -- 4 | -- -- 5 | -- Internal auxiliary routines -- 6 | -- -- 7 | -- The MIT License (MIT) -- 8 | -- -- 9 | -- Copyright (c) 2015 -- 2020 Gustavo A. Hoffmann -- 10 | -- -- 11 | -- Permission is hereby granted, free of charge, to any person obtaining -- 12 | -- a copy of this software and associated documentation files (the -- 13 | -- "Software"), to deal in the Software without restriction, including -- 14 | -- without limitation the rights to use, copy, modify, merge, publish, -- 15 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 16 | -- permit persons to whom the Software is furnished to do so, subject to -- 17 | -- the following conditions: -- 18 | -- -- 19 | -- The above copyright notice and this permission notice shall be -- 20 | -- included in all copies or substantial portions of the Software. -- 21 | -- -- 22 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 23 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 24 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 25 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 26 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 27 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 28 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 29 | ------------------------------------------------------------------------------ 30 | 31 | with Ada.Streams.Stream_IO; 32 | with Interfaces; use Interfaces; 33 | 34 | private 35 | package Audio.Wavefiles.Internals is 36 | 37 | procedure Skip_Bytes 38 | (F : in out Ada.Streams.Stream_IO.File_Type; 39 | Bytes : Unsigned_32); 40 | 41 | procedure Set_File_Index_To_Chunk_Data_Start 42 | (File : Ada.Streams.Stream_IO.File_Type; 43 | Chunk_Start_Index : Ada.Streams.Stream_IO.Positive_Count; 44 | Position_In_Chunk : Ada.Streams.Stream_IO.Count := 0); 45 | 46 | function Number_Of_Bytes 47 | (Position : Sample_Count; 48 | Channels_In_Total : Interfaces.Unsigned_16; 49 | Bits_Per_Sample : Wav_Bit_Depth) 50 | return Ada.Streams.Stream_IO.Count; 51 | 52 | function Number_Of_Samples 53 | (Chunk_Size : Long_Integer; 54 | Channels_In_Total : Interfaces.Unsigned_16; 55 | Bits_Per_Sample : Wav_Bit_Depth) return Sample_Count; 56 | 57 | end Audio.Wavefiles.Internals; 58 | -------------------------------------------------------------------------------- /src/audio-wavefiles-generic_fixed_wav_fixed_pcm_io.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! -- 4 | -- -- 5 | -- WAVEFILES -- 6 | -- -- 7 | -- Wavefile data I/O operations -- 8 | -- -- 9 | -- The MIT License (MIT) -- 10 | -- -- 11 | -- Copyright (c) 2015 -- 2020 Gustavo A. Hoffmann -- 12 | -- -- 13 | -- Permission is hereby granted, free of charge, to any person obtaining -- 14 | -- a copy of this software and associated documentation files (the -- 15 | -- "Software"), to deal in the Software without restriction, including -- 16 | -- without limitation the rights to use, copy, modify, merge, publish, -- 17 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 18 | -- permit persons to whom the Software is furnished to do so, subject to -- 19 | -- the following conditions: -- 20 | -- -- 21 | -- The above copyright notice and this permission notice shall be -- 22 | -- included in all copies or substantial portions of the Software. -- 23 | -- -- 24 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 25 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 26 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 27 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 28 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 29 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 30 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 31 | ------------------------------------------------------------------------------ 32 | 33 | private generic 34 | type Wav_Sample is delta <>; 35 | type PCM_Sample is delta <>; 36 | type Channel_Range is (<>); 37 | type PCM_MC_Sample is array (Channel_Range range <>) of PCM_Sample; 38 | package Audio.Wavefiles.Generic_Fixed_Wav_Fixed_PCM_IO is 39 | 40 | function Get (WF : in out Wavefile) return PCM_MC_Sample 41 | with Pre => Mode (WF) = In_File; 42 | 43 | procedure Get (WF : in out Wavefile; 44 | PCM : out PCM_MC_Sample) 45 | with Pre => Mode (WF) = In_File and 46 | Number_Of_Channels (WF) <= PCM'Length; 47 | 48 | procedure Put (WF : in out Wavefile; 49 | PCM : PCM_MC_Sample) 50 | with Pre => Mode (WF) = Out_File and 51 | Number_Of_Channels (WF) <= PCM'Length; 52 | 53 | end Audio.Wavefiles.Generic_Fixed_Wav_Fixed_PCM_IO; 54 | -------------------------------------------------------------------------------- /src/audio-wavefiles-generic_fixed_wav_float_pcm_io.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! -- 4 | -- -- 5 | -- WAVEFILES -- 6 | -- -- 7 | -- Wavefile data I/O operations -- 8 | -- -- 9 | -- The MIT License (MIT) -- 10 | -- -- 11 | -- Copyright (c) 2015 -- 2020 Gustavo A. Hoffmann -- 12 | -- -- 13 | -- Permission is hereby granted, free of charge, to any person obtaining -- 14 | -- a copy of this software and associated documentation files (the -- 15 | -- "Software"), to deal in the Software without restriction, including -- 16 | -- without limitation the rights to use, copy, modify, merge, publish, -- 17 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 18 | -- permit persons to whom the Software is furnished to do so, subject to -- 19 | -- the following conditions: -- 20 | -- -- 21 | -- The above copyright notice and this permission notice shall be -- 22 | -- included in all copies or substantial portions of the Software. -- 23 | -- -- 24 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 25 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 26 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 27 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 28 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 29 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 30 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 31 | ------------------------------------------------------------------------------ 32 | 33 | private generic 34 | type Wav_Sample is delta <>; 35 | type PCM_Sample is digits <>; 36 | type Channel_Range is (<>); 37 | type PCM_MC_Sample is array (Channel_Range range <>) of PCM_Sample; 38 | package Audio.Wavefiles.Generic_Fixed_Wav_Float_PCM_IO is 39 | 40 | function Get (WF : in out Wavefile) return PCM_MC_Sample 41 | with Pre => Mode (WF) = In_File; 42 | 43 | procedure Get (WF : in out Wavefile; 44 | PCM : out PCM_MC_Sample) 45 | with Pre => Mode (WF) = In_File and 46 | Number_Of_Channels (WF) <= PCM'Length; 47 | 48 | procedure Put (WF : in out Wavefile; 49 | PCM : PCM_MC_Sample) 50 | with Pre => Mode (WF) = Out_File and 51 | Number_Of_Channels (WF) <= PCM'Length; 52 | 53 | end Audio.Wavefiles.Generic_Fixed_Wav_Float_PCM_IO; 54 | -------------------------------------------------------------------------------- /src/audio-wavefiles-generic_float_wav_fixed_pcm_io.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! -- 4 | -- -- 5 | -- WAVEFILES -- 6 | -- -- 7 | -- Wavefile data I/O operations -- 8 | -- -- 9 | -- The MIT License (MIT) -- 10 | -- -- 11 | -- Copyright (c) 2015 -- 2020 Gustavo A. Hoffmann -- 12 | -- -- 13 | -- Permission is hereby granted, free of charge, to any person obtaining -- 14 | -- a copy of this software and associated documentation files (the -- 15 | -- "Software"), to deal in the Software without restriction, including -- 16 | -- without limitation the rights to use, copy, modify, merge, publish, -- 17 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 18 | -- permit persons to whom the Software is furnished to do so, subject to -- 19 | -- the following conditions: -- 20 | -- -- 21 | -- The above copyright notice and this permission notice shall be -- 22 | -- included in all copies or substantial portions of the Software. -- 23 | -- -- 24 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 25 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 26 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 27 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 28 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 29 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 30 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 31 | ------------------------------------------------------------------------------ 32 | 33 | private generic 34 | type Wav_Sample is digits <>; 35 | type PCM_Sample is delta <>; 36 | type Channel_Range is (<>); 37 | type PCM_MC_Sample is array (Channel_Range range <>) of PCM_Sample; 38 | package Audio.Wavefiles.Generic_Float_Wav_Fixed_PCM_IO is 39 | 40 | function Get (WF : in out Wavefile) return PCM_MC_Sample 41 | with Pre => Mode (WF) = In_File; 42 | 43 | procedure Get (WF : in out Wavefile; 44 | PCM : out PCM_MC_Sample) 45 | with Pre => Mode (WF) = In_File and 46 | Number_Of_Channels (WF) <= PCM'Length; 47 | 48 | procedure Put (WF : in out Wavefile; 49 | PCM : PCM_MC_Sample) 50 | with Pre => Mode (WF) = Out_File and 51 | Number_Of_Channels (WF) <= PCM'Length; 52 | 53 | end Audio.Wavefiles.Generic_Float_Wav_Fixed_PCM_IO; 54 | -------------------------------------------------------------------------------- /src/audio-wavefiles-generic_float_wav_float_pcm_io.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! -- 4 | -- -- 5 | -- WAVEFILES -- 6 | -- -- 7 | -- Wavefile data I/O operations -- 8 | -- -- 9 | -- The MIT License (MIT) -- 10 | -- -- 11 | -- Copyright (c) 2015 -- 2020 Gustavo A. Hoffmann -- 12 | -- -- 13 | -- Permission is hereby granted, free of charge, to any person obtaining -- 14 | -- a copy of this software and associated documentation files (the -- 15 | -- "Software"), to deal in the Software without restriction, including -- 16 | -- without limitation the rights to use, copy, modify, merge, publish, -- 17 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 18 | -- permit persons to whom the Software is furnished to do so, subject to -- 19 | -- the following conditions: -- 20 | -- -- 21 | -- The above copyright notice and this permission notice shall be -- 22 | -- included in all copies or substantial portions of the Software. -- 23 | -- -- 24 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 25 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 26 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 27 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 28 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 29 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 30 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 31 | ------------------------------------------------------------------------------ 32 | 33 | private generic 34 | type Wav_Sample is digits <>; 35 | type PCM_Sample is digits <>; 36 | type Channel_Range is (<>); 37 | type PCM_MC_Sample is array (Channel_Range range <>) of PCM_Sample; 38 | package Audio.Wavefiles.Generic_Float_Wav_Float_PCM_IO is 39 | 40 | function Get (WF : in out Wavefile) return PCM_MC_Sample 41 | with Pre => Mode (WF) = In_File; 42 | 43 | procedure Get (WF : in out Wavefile; 44 | PCM : out PCM_MC_Sample) 45 | with Pre => Mode (WF) = In_File and 46 | Number_Of_Channels (WF) <= PCM'Length; 47 | 48 | procedure Put (WF : in out Wavefile; 49 | PCM : PCM_MC_Sample) 50 | with Pre => Mode (WF) = Out_File and 51 | Number_Of_Channels (WF) <= PCM'Length; 52 | 53 | end Audio.Wavefiles.Generic_Float_Wav_Float_PCM_IO; 54 | -------------------------------------------------------------------------------- /test/wavefiles_test/src.prep/generic_NUM_TYPE_pcm_buffer_ops.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! -- 4 | -- -- 5 | -- WAVEFILES -- 6 | -- -- 7 | -- Test application -- 8 | -- -- 9 | -- The MIT License (MIT) -- 10 | -- -- 11 | -- Copyright (c) 2020 Gustavo A. Hoffmann -- 12 | -- -- 13 | -- Permission is hereby granted, free of charge, to any person obtaining -- 14 | -- a copy of this software and associated documentation files (the -- 15 | -- "Software"), to deal in the Software without restriction, including -- 16 | -- without limitation the rights to use, copy, modify, merge, publish, -- 17 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 18 | -- permit persons to whom the Software is furnished to do so, subject to -- 19 | -- the following conditions: -- 20 | -- -- 21 | -- The above copyright notice and this permission notice shall be -- 22 | -- included in all copies or substantial portions of the Software. -- 23 | -- -- 24 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 25 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 26 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 27 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 28 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 29 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 30 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 31 | ------------------------------------------------------------------------------ 32 | 33 | generic 34 | #if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then 35 | type PCM_Sample is digits <>; 36 | #else 37 | type PCM_Sample is delta <>; 38 | #end if; 39 | type PCM_MC_Sample is array (Positive range <>) of PCM_Sample; 40 | #if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then 41 | package Generic_Float_PCM_Buffer_Ops is 42 | #else 43 | package Generic_Fixed_PCM_Buffer_Ops is 44 | #end if; 45 | 46 | function "+" (PCM_Ref : PCM_MC_Sample; 47 | PCM_DUT : PCM_MC_Sample) 48 | return PCM_MC_Sample; 49 | 50 | function "-" (PCM_Ref : PCM_MC_Sample; 51 | PCM_DUT : PCM_MC_Sample) 52 | return PCM_MC_Sample; 53 | 54 | #if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then 55 | end Generic_Float_PCM_Buffer_Ops; 56 | #else 57 | end Generic_Fixed_PCM_Buffer_Ops; 58 | #end if; 59 | -------------------------------------------------------------------------------- /src/audio-wavefiles-generic_direct_fixed_wav_io.adb: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! -- 4 | -- -- 5 | -- WAVEFILES -- 6 | -- -- 7 | -- Wavefile data I/O operations -- 8 | -- -- 9 | -- The MIT License (MIT) -- 10 | -- -- 11 | -- Copyright (c) 2015 -- 2021 Gustavo A. Hoffmann -- 12 | -- -- 13 | -- Permission is hereby granted, free of charge, to any person obtaining -- 14 | -- a copy of this software and associated documentation files (the -- 15 | -- "Software"), to deal in the Software without restriction, including -- 16 | -- without limitation the rights to use, copy, modify, merge, publish, -- 17 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 18 | -- permit persons to whom the Software is furnished to do so, subject to -- 19 | -- the following conditions: -- 20 | -- -- 21 | -- The above copyright notice and this permission notice shall be -- 22 | -- included in all copies or substantial portions of the Software. -- 23 | -- -- 24 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 25 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 26 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 27 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 28 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 29 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 30 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 31 | ------------------------------------------------------------------------------ 32 | 33 | with Audio.Wavefiles.Generic_Fixed_Wav_IO; 34 | 35 | package body Audio.Wavefiles.Generic_Direct_Fixed_Wav_IO is 36 | 37 | package Wav_IO is new Audio.Wavefiles.Generic_Fixed_Wav_IO 38 | (Wav_Sample => Wav_Sample, 39 | Channel_Range => Channel_Range, 40 | Wav_MC_Sample => Wav_MC_Sample); 41 | 42 | --------- 43 | -- Get -- 44 | --------- 45 | 46 | function Get (WF : in out Wavefile) return Wav_MC_Sample is 47 | (Wav_IO.Get (WF)); 48 | 49 | --------- 50 | -- Get -- 51 | --------- 52 | 53 | procedure Get (WF : in out Wavefile; 54 | Wav : out Wav_MC_Sample) is 55 | begin 56 | Wav_IO.Get (WF, Wav); 57 | end Get; 58 | 59 | --------- 60 | -- Put -- 61 | --------- 62 | 63 | procedure Put (WF : in out Wavefile; 64 | Wav : Wav_MC_Sample) is 65 | begin 66 | Wav_IO.Put (WF, Wav); 67 | end Put; 68 | 69 | end Audio.Wavefiles.Generic_Direct_Fixed_Wav_IO; 70 | -------------------------------------------------------------------------------- /src/audio-wavefiles-generic_direct_float_wav_io.adb: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! -- 4 | -- -- 5 | -- WAVEFILES -- 6 | -- -- 7 | -- Wavefile data I/O operations -- 8 | -- -- 9 | -- The MIT License (MIT) -- 10 | -- -- 11 | -- Copyright (c) 2015 -- 2021 Gustavo A. Hoffmann -- 12 | -- -- 13 | -- Permission is hereby granted, free of charge, to any person obtaining -- 14 | -- a copy of this software and associated documentation files (the -- 15 | -- "Software"), to deal in the Software without restriction, including -- 16 | -- without limitation the rights to use, copy, modify, merge, publish, -- 17 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 18 | -- permit persons to whom the Software is furnished to do so, subject to -- 19 | -- the following conditions: -- 20 | -- -- 21 | -- The above copyright notice and this permission notice shall be -- 22 | -- included in all copies or substantial portions of the Software. -- 23 | -- -- 24 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 25 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 26 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 27 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 28 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 29 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 30 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 31 | ------------------------------------------------------------------------------ 32 | 33 | with Audio.Wavefiles.Generic_Float_Wav_IO; 34 | 35 | package body Audio.Wavefiles.Generic_Direct_Float_Wav_IO is 36 | 37 | package Wav_IO is new Audio.Wavefiles.Generic_Float_Wav_IO 38 | (Wav_Sample => Wav_Sample, 39 | Channel_Range => Channel_Range, 40 | Wav_MC_Sample => Wav_MC_Sample); 41 | 42 | --------- 43 | -- Get -- 44 | --------- 45 | 46 | function Get (WF : in out Wavefile) return Wav_MC_Sample is 47 | (Wav_IO.Get (WF)); 48 | 49 | --------- 50 | -- Get -- 51 | --------- 52 | 53 | procedure Get (WF : in out Wavefile; 54 | Wav : out Wav_MC_Sample) is 55 | begin 56 | Wav_IO.Get (WF, Wav); 57 | end Get; 58 | 59 | --------- 60 | -- Put -- 61 | --------- 62 | 63 | procedure Put (WF : in out Wavefile; 64 | Wav : Wav_MC_Sample) is 65 | begin 66 | Wav_IO.Put (WF, Wav); 67 | end Put; 68 | 69 | end Audio.Wavefiles.Generic_Direct_Float_Wav_IO; 70 | -------------------------------------------------------------------------------- /src.prep/audio-wavefiles-generic_NUM_TYPE_pcm_io.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! -- 4 | -- -- 5 | -- WAVEFILES -- 6 | -- -- 7 | -- Wavefile I/O operations for PCM buffers -- 8 | -- -- 9 | -- The MIT License (MIT) -- 10 | -- -- 11 | -- Copyright (c) 2015 -- 2020 Gustavo A. Hoffmann -- 12 | -- -- 13 | -- Permission is hereby granted, free of charge, to any person obtaining -- 14 | -- a copy of this software and associated documentation files (the -- 15 | -- "Software"), to deal in the Software without restriction, including -- 16 | -- without limitation the rights to use, copy, modify, merge, publish, -- 17 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 18 | -- permit persons to whom the Software is furnished to do so, subject to -- 19 | -- the following conditions: -- 20 | -- -- 21 | -- The above copyright notice and this permission notice shall be -- 22 | -- included in all copies or substantial portions of the Software. -- 23 | -- -- 24 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 25 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 26 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 27 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 28 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 29 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 30 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 31 | ------------------------------------------------------------------------------ 32 | 33 | generic 34 | #if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then 35 | type PCM_Sample is digits <>; 36 | #else 37 | type PCM_Sample is delta <>; 38 | #end if; 39 | type Channel_Range is (<>); 40 | type PCM_MC_Sample is array (Channel_Range range <>) of PCM_Sample; 41 | #if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then 42 | package Audio.Wavefiles.Generic_Float_PCM_IO is 43 | #else 44 | package Audio.Wavefiles.Generic_Fixed_PCM_IO is 45 | #end if; 46 | 47 | function Get 48 | (WF : in out Wavefile) return PCM_MC_Sample 49 | with Inline, Pre => Mode (WF) = In_File; 50 | 51 | procedure Get 52 | (WF : in out Wavefile; 53 | PCM : out PCM_MC_Sample) 54 | with Inline, Pre => Mode (WF) = In_File; 55 | 56 | procedure Put 57 | (WF : in out Wavefile; 58 | PCM : PCM_MC_Sample) 59 | with Pre => Mode (WF) = Out_File; 60 | 61 | #if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then 62 | end Audio.Wavefiles.Generic_Float_PCM_IO; 63 | #else 64 | end Audio.Wavefiles.Generic_Fixed_PCM_IO; 65 | #end if; 66 | -------------------------------------------------------------------------------- /src/audio-riff-wav-formats-standard_channel_configurations.adb: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- AUDIO / RIFF / WAV -- 4 | -- -- 5 | -- Standard channel configurations for wavefiles -- 6 | -- -- 7 | -- The MIT License (MIT) -- 8 | -- -- 9 | -- Copyright (c) 2020 Gustavo A. Hoffmann -- 10 | -- -- 11 | -- Permission is hereby granted, free of charge, to any person obtaining -- 12 | -- a copy of this software and associated documentation files (the -- 13 | -- "Software"), to deal in the Software without restriction, including -- 14 | -- without limitation the rights to use, copy, modify, merge, publish, -- 15 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 16 | -- permit persons to whom the Software is furnished to do so, subject to -- 17 | -- the following conditions: -- 18 | -- -- 19 | -- The above copyright notice and this permission notice shall be -- 20 | -- included in all copies or substantial portions of the Software. -- 21 | -- -- 22 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 23 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 24 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 25 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 26 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 27 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 28 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 29 | ------------------------------------------------------------------------------ 30 | 31 | package body Audio.RIFF.Wav.Formats.Standard_Channel_Configurations is 32 | 33 | ----------------------------------- 34 | -- Guessed_Channel_Configuration -- 35 | ----------------------------------- 36 | 37 | function Guessed_Channel_Configuration 38 | (Number_Of_Channels : Positive) return Channel_Configuration is 39 | begin 40 | case Number_Of_Channels is 41 | when 1 => return Channel_Config_1_0; 42 | when 2 => return Channel_Config_2_0; 43 | when 3 => return Channel_Config_3_0; 44 | when 4 => return Channel_Config_4_0; 45 | when 5 => return Channel_Config_5_0; 46 | when 6 => return Channel_Config_5_1; 47 | when 7 => return Channel_Config_7_0; 48 | when 8 => return Channel_Config_7_1; 49 | when 9 => return Channel_Config_7_1_BC; 50 | when 10 => return Channel_Config_5_1_4; 51 | -- return Channel_Config_7_1_2; 52 | when 11 => return Channel_Config_7_0_4; 53 | when 12 => return Channel_Config_7_1_4; 54 | when others => return Channel_Config_Empty; 55 | end case; 56 | end Guessed_Channel_Configuration; 57 | 58 | end Audio.RIFF.Wav.Formats.Standard_Channel_Configurations; 59 | -------------------------------------------------------------------------------- /test/wavefiles_test/src.prep/generic_NUM_TYPE_wave_test.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! -- 4 | -- -- 5 | -- WAVEFILES -- 6 | -- -- 7 | -- Test application -- 8 | -- -- 9 | -- The MIT License (MIT) -- 10 | -- -- 11 | -- Copyright (c) 2015 -- 2020 Gustavo A. Hoffmann -- 12 | -- -- 13 | -- Permission is hereby granted, free of charge, to any person obtaining -- 14 | -- a copy of this software and associated documentation files (the -- 15 | -- "Software"), to deal in the Software without restriction, including -- 16 | -- without limitation the rights to use, copy, modify, merge, publish, -- 17 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 18 | -- permit persons to whom the Software is furnished to do so, subject to -- 19 | -- the following conditions: -- 20 | -- -- 21 | -- The above copyright notice and this permission notice shall be -- 22 | -- included in all copies or substantial portions of the Software. -- 23 | -- -- 24 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 25 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 26 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 27 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 28 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 29 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 30 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 31 | ------------------------------------------------------------------------------ 32 | 33 | generic 34 | #if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then 35 | type PCM_Sample is digits <>; 36 | #else 37 | type PCM_Sample is delta <>; 38 | #end if; 39 | type PCM_MC_Sample is array (Positive range <>) of PCM_Sample; 40 | #if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then 41 | package Generic_Float_Wave_Test is 42 | #else 43 | package Generic_Fixed_Wave_Test is 44 | #end if; 45 | 46 | procedure Display_Info_File 47 | (File_In : String); 48 | 49 | procedure Copy_File 50 | (File_In : String; 51 | File_Out : String); 52 | 53 | procedure Compare_Files 54 | (File_Ref : String; 55 | File_DUT : String); 56 | 57 | procedure Diff_Files 58 | (File_Ref : String; 59 | File_DUT : String; 60 | File_Diff : String); 61 | 62 | procedure Mix_Files 63 | (File_Ref : String; 64 | File_DUT : String; 65 | File_Mix : String); 66 | 67 | #if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then 68 | end Generic_Float_Wave_Test; 69 | #else 70 | end Generic_Fixed_Wave_Test; 71 | #end if; 72 | -------------------------------------------------------------------------------- /src.prep/audio-wavefiles-generic_NUM_TYPE_wav_io.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! -- 4 | -- -- 5 | -- WAVEFILES -- 6 | -- -- 7 | -- Wavefile data I/O operations -- 8 | -- -- 9 | -- The MIT License (MIT) -- 10 | -- -- 11 | -- Copyright (c) 2015 -- 2021 Gustavo A. Hoffmann -- 12 | -- -- 13 | -- Permission is hereby granted, free of charge, to any person obtaining -- 14 | -- a copy of this software and associated documentation files (the -- 15 | -- "Software"), to deal in the Software without restriction, including -- 16 | -- without limitation the rights to use, copy, modify, merge, publish, -- 17 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 18 | -- permit persons to whom the Software is furnished to do so, subject to -- 19 | -- the following conditions: -- 20 | -- -- 21 | -- The above copyright notice and this permission notice shall be -- 22 | -- included in all copies or substantial portions of the Software. -- 23 | -- -- 24 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 25 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 26 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 27 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 28 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 29 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 30 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 31 | ------------------------------------------------------------------------------ 32 | 33 | private generic 34 | #if (NUM_TYPE = "FLOAT") then 35 | type Wav_Sample is digits <>; 36 | #else 37 | type Wav_Sample is delta <>; 38 | #end if; 39 | type Channel_Range is (<>); 40 | type Wav_MC_Sample is array (Channel_Range range <>) of Wav_Sample; 41 | #if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then 42 | package Audio.Wavefiles.Generic_Float_Wav_IO is 43 | #else 44 | package Audio.Wavefiles.Generic_Fixed_Wav_IO is 45 | #end if; 46 | 47 | function Get (WF : in out Wavefile) return Wav_MC_Sample 48 | with Inline, Pre => Mode (WF) = In_File; 49 | 50 | procedure Get (WF : in out Wavefile; 51 | Wav : out Wav_MC_Sample) 52 | with Inline, Pre => Mode (WF) = In_File; 53 | 54 | procedure Put (WF : in out Wavefile; 55 | Wav : Wav_MC_Sample) 56 | with Inline, 57 | Pre => Mode (WF) = Out_File 58 | and Wav'Length >= Number_Of_Channels (WF); 59 | 60 | #if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then 61 | end Audio.Wavefiles.Generic_Float_Wav_IO; 62 | #else 63 | end Audio.Wavefiles.Generic_Fixed_Wav_IO; 64 | #end if; 65 | -------------------------------------------------------------------------------- /test/wavefiles_test/src/generic_fixed_pcm_buffer_ops.adb: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! -- 4 | -- -- 5 | -- WAVEFILES -- 6 | -- -- 7 | -- Test application -- 8 | -- -- 9 | -- The MIT License (MIT) -- 10 | -- -- 11 | -- Copyright (c) 2020 Gustavo A. Hoffmann -- 12 | -- -- 13 | -- Permission is hereby granted, free of charge, to any person obtaining -- 14 | -- a copy of this software and associated documentation files (the -- 15 | -- "Software"), to deal in the Software without restriction, including -- 16 | -- without limitation the rights to use, copy, modify, merge, publish, -- 17 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 18 | -- permit persons to whom the Software is furnished to do so, subject to -- 19 | -- the following conditions: -- 20 | -- -- 21 | -- The above copyright notice and this permission notice shall be -- 22 | -- included in all copies or substantial portions of the Software. -- 23 | -- -- 24 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 25 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 26 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 27 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 28 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 29 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 30 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 31 | ------------------------------------------------------------------------------ 32 | 33 | package body Generic_Fixed_PCM_Buffer_Ops is 34 | 35 | --------- 36 | -- "+" -- 37 | --------- 38 | 39 | function "+" (PCM_Ref : PCM_MC_Sample; 40 | PCM_DUT : PCM_MC_Sample) 41 | return PCM_MC_Sample 42 | is 43 | Max_Last : constant Positive := 44 | Positive'Max (PCM_Ref'Last, PCM_DUT'Last); 45 | PCM_Sum : PCM_MC_Sample (1 .. Max_Last); 46 | begin 47 | for I in 1 .. Max_Last loop 48 | PCM_Sum (I) := PCM_Ref (I) + PCM_DUT (I); 49 | end loop; 50 | return PCM_Sum; 51 | end "+"; 52 | 53 | --------- 54 | -- "-" -- 55 | --------- 56 | 57 | function "-" (PCM_Ref : PCM_MC_Sample; 58 | PCM_DUT : PCM_MC_Sample) 59 | return PCM_MC_Sample 60 | is 61 | Max_Last : constant Positive := 62 | Positive'Max (PCM_Ref'Last, PCM_DUT'Last); 63 | PCM_Diff : PCM_MC_Sample (1 .. Max_Last); 64 | begin 65 | for I in 1 .. Max_Last loop 66 | PCM_Diff (I) := PCM_Ref (I) - PCM_DUT (I); 67 | end loop; 68 | return PCM_Diff; 69 | end "-"; 70 | 71 | end Generic_Fixed_PCM_Buffer_Ops; 72 | -------------------------------------------------------------------------------- /test/wavefiles_test/src/generic_float_pcm_buffer_ops.adb: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! -- 4 | -- -- 5 | -- WAVEFILES -- 6 | -- -- 7 | -- Test application -- 8 | -- -- 9 | -- The MIT License (MIT) -- 10 | -- -- 11 | -- Copyright (c) 2020 Gustavo A. Hoffmann -- 12 | -- -- 13 | -- Permission is hereby granted, free of charge, to any person obtaining -- 14 | -- a copy of this software and associated documentation files (the -- 15 | -- "Software"), to deal in the Software without restriction, including -- 16 | -- without limitation the rights to use, copy, modify, merge, publish, -- 17 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 18 | -- permit persons to whom the Software is furnished to do so, subject to -- 19 | -- the following conditions: -- 20 | -- -- 21 | -- The above copyright notice and this permission notice shall be -- 22 | -- included in all copies or substantial portions of the Software. -- 23 | -- -- 24 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 25 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 26 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 27 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 28 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 29 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 30 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 31 | ------------------------------------------------------------------------------ 32 | 33 | package body Generic_Float_PCM_Buffer_Ops is 34 | 35 | --------- 36 | -- "+" -- 37 | --------- 38 | 39 | function "+" (PCM_Ref : PCM_MC_Sample; 40 | PCM_DUT : PCM_MC_Sample) 41 | return PCM_MC_Sample 42 | is 43 | Max_Last : constant Positive := 44 | Positive'Max (PCM_Ref'Last, PCM_DUT'Last); 45 | PCM_Sum : PCM_MC_Sample (1 .. Max_Last); 46 | begin 47 | for I in 1 .. Max_Last loop 48 | PCM_Sum (I) := PCM_Ref (I) + PCM_DUT (I); 49 | end loop; 50 | return PCM_Sum; 51 | end "+"; 52 | 53 | --------- 54 | -- "-" -- 55 | --------- 56 | 57 | function "-" (PCM_Ref : PCM_MC_Sample; 58 | PCM_DUT : PCM_MC_Sample) 59 | return PCM_MC_Sample 60 | is 61 | Max_Last : constant Positive := 62 | Positive'Max (PCM_Ref'Last, PCM_DUT'Last); 63 | PCM_Diff : PCM_MC_Sample (1 .. Max_Last); 64 | begin 65 | for I in 1 .. Max_Last loop 66 | PCM_Diff (I) := PCM_Ref (I) - PCM_DUT (I); 67 | end loop; 68 | return PCM_Diff; 69 | end "-"; 70 | 71 | end Generic_Float_PCM_Buffer_Ops; 72 | -------------------------------------------------------------------------------- /src/audio-wavefiles-generic_direct_float_wav_io.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! -- 4 | -- -- 5 | -- WAVEFILES -- 6 | -- -- 7 | -- Wavefile data I/O operations -- 8 | -- -- 9 | -- The MIT License (MIT) -- 10 | -- -- 11 | -- Copyright (c) 2015 -- 2021 Gustavo A. Hoffmann -- 12 | -- -- 13 | -- Permission is hereby granted, free of charge, to any person obtaining -- 14 | -- a copy of this software and associated documentation files (the -- 15 | -- "Software"), to deal in the Software without restriction, including -- 16 | -- without limitation the rights to use, copy, modify, merge, publish, -- 17 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 18 | -- permit persons to whom the Software is furnished to do so, subject to -- 19 | -- the following conditions: -- 20 | -- -- 21 | -- The above copyright notice and this permission notice shall be -- 22 | -- included in all copies or substantial portions of the Software. -- 23 | -- -- 24 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 25 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 26 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 27 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 28 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 29 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 30 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 31 | ------------------------------------------------------------------------------ 32 | 33 | generic 34 | type Wav_Sample is digits <>; 35 | type Channel_Range is (<>); 36 | type Wav_MC_Sample is array (Channel_Range range <>) of Wav_Sample; 37 | package Audio.Wavefiles.Generic_Direct_Float_Wav_IO is 38 | 39 | function Wav_Format_Matches (WF : Wavefile) return Boolean 40 | with Ghost; 41 | 42 | function Get (WF : in out Wavefile) return Wav_MC_Sample 43 | with Inline, Pre => Mode (WF) = In_File 44 | and then Wav_Format_Matches (WF); 45 | 46 | procedure Get (WF : in out Wavefile; 47 | Wav : out Wav_MC_Sample) 48 | with Inline, Pre => Mode (WF) = In_File 49 | and then Wav_Format_Matches (WF); 50 | 51 | procedure Put (WF : in out Wavefile; 52 | Wav : Wav_MC_Sample) 53 | with Inline, 54 | Pre => Mode (WF) = Out_File 55 | and then Wav'Length >= Number_Of_Channels (WF) 56 | and then Wav_Format_Matches (WF); 57 | private 58 | 59 | function Wav_Format_Matches (WF : Wavefile) return Boolean is 60 | (To_Positive (WF.Bit_Depth) = Wav_Sample'Size 61 | and then WF.Format_Of_Wavefile.Is_Float_Format); 62 | 63 | end Audio.Wavefiles.Generic_Direct_Float_Wav_IO; 64 | -------------------------------------------------------------------------------- /src/audio-wavefiles-generic_direct_fixed_wav_io.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! -- 4 | -- -- 5 | -- WAVEFILES -- 6 | -- -- 7 | -- Wavefile data I/O operations -- 8 | -- -- 9 | -- The MIT License (MIT) -- 10 | -- -- 11 | -- Copyright (c) 2015 -- 2021 Gustavo A. Hoffmann -- 12 | -- -- 13 | -- Permission is hereby granted, free of charge, to any person obtaining -- 14 | -- a copy of this software and associated documentation files (the -- 15 | -- "Software"), to deal in the Software without restriction, including -- 16 | -- without limitation the rights to use, copy, modify, merge, publish, -- 17 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 18 | -- permit persons to whom the Software is furnished to do so, subject to -- 19 | -- the following conditions: -- 20 | -- -- 21 | -- The above copyright notice and this permission notice shall be -- 22 | -- included in all copies or substantial portions of the Software. -- 23 | -- -- 24 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 25 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 26 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 27 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 28 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 29 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 30 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 31 | ------------------------------------------------------------------------------ 32 | 33 | generic 34 | type Wav_Sample is delta <>; 35 | type Channel_Range is (<>); 36 | type Wav_MC_Sample is array (Channel_Range range <>) of Wav_Sample; 37 | package Audio.Wavefiles.Generic_Direct_Fixed_Wav_IO is 38 | 39 | function Wav_Format_Matches (WF : Wavefile) return Boolean 40 | with Ghost; 41 | 42 | function Get (WF : in out Wavefile) return Wav_MC_Sample 43 | with Inline, Pre => Mode (WF) = In_File 44 | and then Wav_Format_Matches (WF); 45 | 46 | procedure Get (WF : in out Wavefile; 47 | Wav : out Wav_MC_Sample) 48 | with Inline, Pre => Mode (WF) = In_File 49 | and then Wav_Format_Matches (WF); 50 | 51 | procedure Put (WF : in out Wavefile; 52 | Wav : Wav_MC_Sample) 53 | with Inline, 54 | Pre => Mode (WF) = Out_File 55 | and then Wav'Length >= Number_Of_Channels (WF) 56 | and then Wav_Format_Matches (WF); 57 | private 58 | 59 | function Wav_Format_Matches (WF : Wavefile) return Boolean is 60 | (To_Positive (WF.Bit_Depth) = Wav_Sample'Size 61 | and then not WF.Format_Of_Wavefile.Is_Float_Format); 62 | 63 | end Audio.Wavefiles.Generic_Direct_Fixed_Wav_IO; 64 | -------------------------------------------------------------------------------- /test/wavefiles_test/src.prep/generic_NUM_TYPE_pcm_buffer_ops.adb: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! -- 4 | -- -- 5 | -- WAVEFILES -- 6 | -- -- 7 | -- Test application -- 8 | -- -- 9 | -- The MIT License (MIT) -- 10 | -- -- 11 | -- Copyright (c) 2020 Gustavo A. Hoffmann -- 12 | -- -- 13 | -- Permission is hereby granted, free of charge, to any person obtaining -- 14 | -- a copy of this software and associated documentation files (the -- 15 | -- "Software"), to deal in the Software without restriction, including -- 16 | -- without limitation the rights to use, copy, modify, merge, publish, -- 17 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 18 | -- permit persons to whom the Software is furnished to do so, subject to -- 19 | -- the following conditions: -- 20 | -- -- 21 | -- The above copyright notice and this permission notice shall be -- 22 | -- included in all copies or substantial portions of the Software. -- 23 | -- -- 24 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 25 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 26 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 27 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 28 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 29 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 30 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 31 | ------------------------------------------------------------------------------ 32 | 33 | #if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then 34 | package body Generic_Float_PCM_Buffer_Ops is 35 | #else 36 | package body Generic_Fixed_PCM_Buffer_Ops is 37 | #end if; 38 | 39 | --------- 40 | -- "+" -- 41 | --------- 42 | 43 | function "+" (PCM_Ref : PCM_MC_Sample; 44 | PCM_DUT : PCM_MC_Sample) 45 | return PCM_MC_Sample 46 | is 47 | Max_Last : constant Positive := 48 | Positive'Max (PCM_Ref'Last, PCM_DUT'Last); 49 | PCM_Sum : PCM_MC_Sample (1 .. Max_Last); 50 | begin 51 | for I in 1 .. Max_Last loop 52 | PCM_Sum (I) := PCM_Ref (I) + PCM_DUT (I); 53 | end loop; 54 | return PCM_Sum; 55 | end "+"; 56 | 57 | --------- 58 | -- "-" -- 59 | --------- 60 | 61 | function "-" (PCM_Ref : PCM_MC_Sample; 62 | PCM_DUT : PCM_MC_Sample) 63 | return PCM_MC_Sample 64 | is 65 | Max_Last : constant Positive := 66 | Positive'Max (PCM_Ref'Last, PCM_DUT'Last); 67 | PCM_Diff : PCM_MC_Sample (1 .. Max_Last); 68 | begin 69 | for I in 1 .. Max_Last loop 70 | PCM_Diff (I) := PCM_Ref (I) - PCM_DUT (I); 71 | end loop; 72 | return PCM_Diff; 73 | end "-"; 74 | 75 | #if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then 76 | end Generic_Float_PCM_Buffer_Ops; 77 | #else 78 | end Generic_Fixed_PCM_Buffer_Ops; 79 | #end if; 80 | -------------------------------------------------------------------------------- /src.prep/audio-wavefiles-generic_direct_NUM_TYPE_wav_io.adb: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! -- 4 | -- -- 5 | -- WAVEFILES -- 6 | -- -- 7 | -- Wavefile data I/O operations -- 8 | -- -- 9 | -- The MIT License (MIT) -- 10 | -- -- 11 | -- Copyright (c) 2015 -- 2021 Gustavo A. Hoffmann -- 12 | -- -- 13 | -- Permission is hereby granted, free of charge, to any person obtaining -- 14 | -- a copy of this software and associated documentation files (the -- 15 | -- "Software"), to deal in the Software without restriction, including -- 16 | -- without limitation the rights to use, copy, modify, merge, publish, -- 17 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 18 | -- permit persons to whom the Software is furnished to do so, subject to -- 19 | -- the following conditions: -- 20 | -- -- 21 | -- The above copyright notice and this permission notice shall be -- 22 | -- included in all copies or substantial portions of the Software. -- 23 | -- -- 24 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 25 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 26 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 27 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 28 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 29 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 30 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 31 | ------------------------------------------------------------------------------ 32 | 33 | #if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then 34 | with Audio.Wavefiles.Generic_Float_Wav_IO; 35 | 36 | package body Audio.Wavefiles.Generic_Direct_Float_Wav_IO is 37 | #else 38 | with Audio.Wavefiles.Generic_Fixed_Wav_IO; 39 | 40 | package body Audio.Wavefiles.Generic_Direct_Fixed_Wav_IO is 41 | #end if; 42 | 43 | #if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then 44 | package Wav_IO is new Audio.Wavefiles.Generic_Float_Wav_IO 45 | #else 46 | package Wav_IO is new Audio.Wavefiles.Generic_Fixed_Wav_IO 47 | #end if; 48 | (Wav_Sample => Wav_Sample, 49 | Channel_Range => Channel_Range, 50 | Wav_MC_Sample => Wav_MC_Sample); 51 | 52 | --------- 53 | -- Get -- 54 | --------- 55 | 56 | function Get (WF : in out Wavefile) return Wav_MC_Sample is 57 | (Wav_IO.Get (WF)); 58 | 59 | --------- 60 | -- Get -- 61 | --------- 62 | 63 | procedure Get (WF : in out Wavefile; 64 | Wav : out Wav_MC_Sample) is 65 | begin 66 | Wav_IO.Get (WF, Wav); 67 | end Get; 68 | 69 | --------- 70 | -- Put -- 71 | --------- 72 | 73 | procedure Put (WF : in out Wavefile; 74 | Wav : Wav_MC_Sample) is 75 | begin 76 | Wav_IO.Put (WF, Wav); 77 | end Put; 78 | 79 | #if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then 80 | end Audio.Wavefiles.Generic_Direct_Float_Wav_IO; 81 | #else 82 | end Audio.Wavefiles.Generic_Direct_Fixed_Wav_IO; 83 | #end if; 84 | -------------------------------------------------------------------------------- /test/simple_benchmarking/src/time_span_conversions.adb: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- WAVEFILES -- 4 | -- -- 5 | -- Wavefile benchmarking -- 6 | -- -- 7 | -- The MIT License (MIT) -- 8 | -- -- 9 | -- Copyright (c) 2020 Gustavo A. Hoffmann -- 10 | -- -- 11 | -- Permission is hereby granted, free of charge, to any person obtaining -- 12 | -- a copy of this software and associated documentation files (the -- 13 | -- "Software"), to deal in the Software without restriction, including -- 14 | -- without limitation the rights to use, copy, modify, merge, publish, -- 15 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 16 | -- permit persons to whom the Software is furnished to do so, subject to -- 17 | -- the following conditions: -- 18 | -- -- 19 | -- The above copyright notice and this permission notice shall be -- 20 | -- included in all copies or substantial portions of the Software. -- 21 | -- -- 22 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 23 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 24 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 25 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 26 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 27 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 28 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 29 | ------------------------------------------------------------------------------ 30 | 31 | with Ada.Text_IO; use Ada.Text_IO; 32 | 33 | package body Time_Span_Conversions is 34 | 35 | Display_Debug_Info : constant Boolean := False; 36 | 37 | ------------ 38 | -- To_MHz -- 39 | ------------ 40 | 41 | function To_MHz (Elapsed_Time : Time_Span; 42 | CPU_MHz : Float; 43 | Factor : Long_Long_Float) return Float 44 | is 45 | Dur : constant Long_Long_Float := 46 | Long_Long_Float (To_Duration (Elapsed_Time)); 47 | -- Elapsed time in seconds 48 | begin 49 | if Display_Debug_Info then 50 | Put_Line ("Dur: " & Long_Long_Float'Image (Dur)); 51 | Put_Line ("Factor: " & Long_Long_Float'Image (Factor)); 52 | end if; 53 | 54 | return Float 55 | (Long_Long_Float (CPU_MHz) * Dur / Factor); 56 | end To_MHz; 57 | 58 | ------------ 59 | -- To_kHz -- 60 | ------------ 61 | 62 | function To_kHz (Elapsed_Time : Time_Span; 63 | CPU_MHz : Float; 64 | Factor : Long_Long_Float) return Float is 65 | (To_MHz (Elapsed_Time, CPU_MHz, Factor) * 10.0 ** 3); 66 | 67 | -------------------- 68 | -- To_Miliseconds -- 69 | -------------------- 70 | 71 | function To_Miliseconds (Elapsed_Time : Time_Span) return Float is 72 | 73 | T : constant Float := Float (To_Duration (Elapsed_Time)); 74 | begin 75 | return T * 10.0 ** 3; 76 | end To_Miliseconds; 77 | 78 | -------------------- 79 | -- To_Nanoseconds -- 80 | -------------------- 81 | 82 | function To_Nanoseconds (Elapsed_Time : Time_Span) return Float is 83 | 84 | T : constant Float := Float (To_Duration (Elapsed_Time)); 85 | begin 86 | return T * 10.0 ** 9; 87 | end To_Nanoseconds; 88 | 89 | end Time_Span_Conversions; 90 | -------------------------------------------------------------------------------- /src.prep/audio-wavefiles-generic_direct_NUM_TYPE_wav_io.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! -- 4 | -- -- 5 | -- WAVEFILES -- 6 | -- -- 7 | -- Wavefile data I/O operations -- 8 | -- -- 9 | -- The MIT License (MIT) -- 10 | -- -- 11 | -- Copyright (c) 2015 -- 2021 Gustavo A. Hoffmann -- 12 | -- -- 13 | -- Permission is hereby granted, free of charge, to any person obtaining -- 14 | -- a copy of this software and associated documentation files (the -- 15 | -- "Software"), to deal in the Software without restriction, including -- 16 | -- without limitation the rights to use, copy, modify, merge, publish, -- 17 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 18 | -- permit persons to whom the Software is furnished to do so, subject to -- 19 | -- the following conditions: -- 20 | -- -- 21 | -- The above copyright notice and this permission notice shall be -- 22 | -- included in all copies or substantial portions of the Software. -- 23 | -- -- 24 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 25 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 26 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 27 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 28 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 29 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 30 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 31 | ------------------------------------------------------------------------------ 32 | 33 | generic 34 | #if (NUM_TYPE = "FLOAT") then 35 | type Wav_Sample is digits <>; 36 | #else 37 | type Wav_Sample is delta <>; 38 | #end if; 39 | type Channel_Range is (<>); 40 | type Wav_MC_Sample is array (Channel_Range range <>) of Wav_Sample; 41 | #if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then 42 | package Audio.Wavefiles.Generic_Direct_Float_Wav_IO is 43 | #else 44 | package Audio.Wavefiles.Generic_Direct_Fixed_Wav_IO is 45 | #end if; 46 | 47 | function Wav_Format_Matches (WF : Wavefile) return Boolean 48 | with Ghost; 49 | 50 | function Get (WF : in out Wavefile) return Wav_MC_Sample 51 | with Inline, Pre => Mode (WF) = In_File 52 | and then Wav_Format_Matches (WF); 53 | 54 | procedure Get (WF : in out Wavefile; 55 | Wav : out Wav_MC_Sample) 56 | with Inline, Pre => Mode (WF) = In_File 57 | and then Wav_Format_Matches (WF); 58 | 59 | procedure Put (WF : in out Wavefile; 60 | Wav : Wav_MC_Sample) 61 | with Inline, 62 | Pre => Mode (WF) = Out_File 63 | and then Wav'Length >= Number_Of_Channels (WF) 64 | and then Wav_Format_Matches (WF); 65 | private 66 | 67 | function Wav_Format_Matches (WF : Wavefile) return Boolean is 68 | (To_Positive (WF.Bit_Depth) = Wav_Sample'Size 69 | #if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then 70 | and then WF.Format_Of_Wavefile.Is_Float_Format); 71 | #else 72 | and then not WF.Format_Of_Wavefile.Is_Float_Format); 73 | #end if; 74 | 75 | #if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then 76 | end Audio.Wavefiles.Generic_Direct_Float_Wav_IO; 77 | #else 78 | end Audio.Wavefiles.Generic_Direct_Fixed_Wav_IO; 79 | #end if; 80 | -------------------------------------------------------------------------------- /cookbook/ref/2020-08-09.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | A=PCM,F=48000,W=16,M=stereo,T=Nuendo 5 | Nuendo 6 | 0.00 7 | -16.05 8 | -14.41 9 | -80.00 10 | -5.21 11 | 2020-10-29 12 | 21:12:55 13 | Nuendo 14 | CCOOONNNNNNNNNNNN211255RRRRRRRRR 15 | 0 16 | 0 17 | 31065BC484024202AA2D830E912D2B92 18 | 19 | 2020-08-09 20 | 21 | 30/1 22 | 23 | 24 | 25 | 26 | 2 27 | AudioSampleFormatSize 28 | int 29 | 2 30 | 31 | 32 | 2 33 | AudioSpeakerArrangement 34 | int 35 | 1 36 | 37 | 38 | GACAssetLength 39 | float 40 | 2.0 41 | 42 | 43 | GACAssetStartTime 44 | float 45 | 0.0 46 | 47 | 48 | GACProjectPath 49 | string 50 | M:\music\Nuendo_Projects\2020-08-09\2020-08-09.npr 51 | 52 | 53 | 2 54 | MediaDropFrames 55 | int 56 | 0 57 | 58 | 59 | 2 60 | MediaDuration 61 | float 62 | 1200.0 63 | 64 | 65 | 2 66 | MediaPullFactor 67 | float 68 | 1.0 69 | 70 | 71 | 2 72 | MediaStartTime 73 | float 74 | 0.0 75 | 76 | 77 | 2 78 | MediaTrackTitle 79 | string 80 | Stereo Out 81 | 82 | 83 | MusicalBeats 84 | int 85 | 4 86 | 87 | 88 | 4 89 | MusicalSignature 90 | 4 91 | rational 92 | 93 | 94 | MusicalTempo 95 | float 96 | 120.0 97 | 98 | 99 | 1 100 | MusicalUpTempo 101 | float 102 | 120.0 103 | 104 | 105 | 1 106 | MusicalUpbeat 107 | float 108 | 0.0 109 | 110 | 111 | 2 112 | ProgramName 113 | string 114 | Nuendo 115 | 116 | 117 | 2 118 | ProgramVersion 119 | string 120 | Version 10.3.0 121 | 122 | 123 | TempoSync 124 | int 125 | 0 126 | 127 | 128 | 129 | 130 | 131 | 1 132 | L-MIX 133 | 1 134 | 135 | 136 | 2 137 | R-MIX 138 | 2 139 | 140 | 2 141 | 142 | 143 | 144 | -------------------------------------------------------------------------------- /cookbook/cookbook.gpr: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | -- 3 | -- WAVEFILES 4 | -- 5 | -- Cookbook 6 | -- 7 | -- The MIT License (MIT) 8 | -- 9 | -- Copyright (c) 2020 Gustavo A. Hoffmann 10 | -- 11 | -- Permission is hereby granted, free of charge, to any person obtaining a 12 | -- copy of this software and associated documentation files (the "Software"), 13 | -- to deal in the Software without restriction, including without limitation 14 | -- the rights to use, copy, modify, merge, publish, distribute, sublicense, 15 | -- and / or sell copies of the Software, and to permit persons to whom the 16 | -- Software is furnished to do so, subject to the following conditions: 17 | -- 18 | -- The above copyright notice and this permission notice shall be included in 19 | -- all copies or substantial portions of the Software. 20 | -- 21 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 27 | -- DEALINGS IN THE SOFTWARE. 28 | ------------------------------------------------------------------------------- 29 | 30 | with "audio_wavefiles.gpr"; 31 | 32 | project Cookbook is 33 | 34 | type Build_Type is ("DEBUG", "RELEASE"); 35 | 36 | Build : Build_Type := 37 | External ("WAVEFILES_BUILD_MODE", External ("BUILD", "DEBUG")); 38 | 39 | for Source_Dirs use ("src/**"); 40 | for Object_Dir use "./obj"; 41 | for Exec_Dir use "./bin"; 42 | for Create_Missing_Dirs use "True"; 43 | 44 | for Main use ("open_close_wavefile_for_reading.adb", 45 | "open_close_wavefile_for_writing.adb", 46 | "display_errors_for_wavefiles.adb", 47 | "list_errors_for_wavefiles.adb", 48 | "display_riff_chunks.adb", 49 | "read_display_wavefile_data.adb", 50 | "write_mono_silence_wavefile.adb", 51 | "write_stereo_sine_wavefile.adb", 52 | "write_5_1_channel_sine_wavefile.adb", 53 | "write_7_1_4_channel_sine_wavefile.adb", 54 | "display_channel_config.adb", 55 | "append_wavefile.adb", 56 | "copy_wavefile.adb", 57 | "copy_wavefile_using_fixed_point_buffer.adb", 58 | "copy_parts_of_wavefile.adb", 59 | "convert_fixed_to_float_wavefile.adb", 60 | "downmix_stereo_to_mono_wavefile.adb", 61 | "downmix_5_1_to_2_0_wavefile.adb", 62 | "downmix_7_1_4_to_5_1_wavefile.adb", 63 | "direct_copy_wavefile.adb", 64 | "direct_copy_float_wavefile.adb", 65 | "convert_8_bit_to_16_bit_wavefile.adb", 66 | "read_to_memory_channel_interleaved.adb", 67 | "read_to_memory_per_channel.adb", 68 | "extract_xml_chunk.adb"); 69 | 70 | package Ide is 71 | for Vcs_Kind use "git"; 72 | end Ide; 73 | 74 | package Compiler is 75 | case Build is 76 | when "DEBUG" => 77 | for Switches ("ada") use ("-g", "-O0", 78 | "-gnata", "-gnato", "-gnatVa", 79 | "-gnatwa", "-fstack-check", "-gnaty3ACIM79Oabcdefhiklnprstux"); 80 | when "RELEASE" => 81 | for Switches ("Ada") use ("-O2", "-gnatn", "-gnatp", "-gnatwa", 82 | "-gnaty3ACIM79Oabcdefhiklnprstux"); 83 | end case; 84 | -- for Switches ("Ada") use ("-gnatp", "-O3"); 85 | end Compiler; 86 | 87 | package Linker is 88 | for Default_Switches ("ada") use ("-g"); 89 | end Linker; 90 | 91 | package Builder is 92 | for Default_Switches ("ada") use ("-g", "-s"); 93 | end Builder; 94 | 95 | package Pretty_Printer is 96 | for Default_Switches ("ada") use ("-A0", "-A1", "-A2", "-A3", "-A4", "-A5", "-c4", "-c3", "--separate-loop-then"); 97 | end Pretty_Printer; 98 | 99 | end Cookbook; 100 | -------------------------------------------------------------------------------- /src.prep/audio-wavefiles-generic_NUM_TYPE_wav_NUM_TYPE_2_pcm_io.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! -- 4 | -- -- 5 | -- WAVEFILES -- 6 | -- -- 7 | -- Wavefile data I/O operations -- 8 | -- -- 9 | -- The MIT License (MIT) -- 10 | -- -- 11 | -- Copyright (c) 2015 -- 2020 Gustavo A. Hoffmann -- 12 | -- -- 13 | -- Permission is hereby granted, free of charge, to any person obtaining -- 14 | -- a copy of this software and associated documentation files (the -- 15 | -- "Software"), to deal in the Software without restriction, including -- 16 | -- without limitation the rights to use, copy, modify, merge, publish, -- 17 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 18 | -- permit persons to whom the Software is furnished to do so, subject to -- 19 | -- the following conditions: -- 20 | -- -- 21 | -- The above copyright notice and this permission notice shall be -- 22 | -- included in all copies or substantial portions of the Software. -- 23 | -- -- 24 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 25 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 26 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 27 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 28 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 29 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 30 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 31 | ------------------------------------------------------------------------------ 32 | 33 | private generic 34 | #if (NUM_TYPE = "FLOAT") then 35 | type Wav_Sample is digits <>; 36 | #else 37 | type Wav_Sample is delta <>; 38 | #end if; 39 | #if (NUM_TYPE_2 = "FLOAT") then 40 | type PCM_Sample is digits <>; 41 | #else 42 | type PCM_Sample is delta <>; 43 | #end if; 44 | type Channel_Range is (<>); 45 | type PCM_MC_Sample is array (Channel_Range range <>) of PCM_Sample; 46 | #if (NUM_TYPE = "FLOAT") and then (NUM_TYPE_2 = "FLOAT") then 47 | package Audio.Wavefiles.Generic_Float_Wav_Float_PCM_IO is 48 | #elsif (NUM_TYPE = "FLOAT") and then (NUM_TYPE_2 = "FIXED") then 49 | package Audio.Wavefiles.Generic_Float_Wav_Fixed_PCM_IO is 50 | #elsif (NUM_TYPE = "FIXED") and then (NUM_TYPE_2 = "FLOAT") then 51 | package Audio.Wavefiles.Generic_Fixed_Wav_Float_PCM_IO is 52 | #elsif (NUM_TYPE = "FIXED") and then (NUM_TYPE_2 = "FIXED") then 53 | package Audio.Wavefiles.Generic_Fixed_Wav_Fixed_PCM_IO is 54 | #end if; 55 | 56 | function Get (WF : in out Wavefile) return PCM_MC_Sample 57 | with Pre => Mode (WF) = In_File; 58 | 59 | procedure Get (WF : in out Wavefile; 60 | PCM : out PCM_MC_Sample) 61 | with Pre => Mode (WF) = In_File and 62 | Number_Of_Channels (WF) <= PCM'Length; 63 | 64 | procedure Put (WF : in out Wavefile; 65 | PCM : PCM_MC_Sample) 66 | with Pre => Mode (WF) = Out_File and 67 | Number_Of_Channels (WF) <= PCM'Length; 68 | 69 | #if (NUM_TYPE = "FLOAT") and then (NUM_TYPE_2 = "FLOAT") then 70 | end Audio.Wavefiles.Generic_Float_Wav_Float_PCM_IO; 71 | #elsif (NUM_TYPE = "FLOAT") and then (NUM_TYPE_2 = "FIXED") then 72 | end Audio.Wavefiles.Generic_Float_Wav_Fixed_PCM_IO; 73 | #elsif (NUM_TYPE = "FIXED") and then (NUM_TYPE_2 = "FLOAT") then 74 | end Audio.Wavefiles.Generic_Fixed_Wav_Float_PCM_IO; 75 | #elsif (NUM_TYPE = "FIXED") and then (NUM_TYPE_2 = "FIXED") then 76 | end Audio.Wavefiles.Generic_Fixed_Wav_Fixed_PCM_IO; 77 | #end if; 78 | -------------------------------------------------------------------------------- /test/simple_benchmarking/src/wavefile_benchmarking-statistics.adb: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- WAVEFILES -- 4 | -- -- 5 | -- Wavefile benchmarking -- 6 | -- -- 7 | -- The MIT License (MIT) -- 8 | -- -- 9 | -- Copyright (c) 2020 Gustavo A. Hoffmann -- 10 | -- -- 11 | -- Permission is hereby granted, free of charge, to any person obtaining -- 12 | -- a copy of this software and associated documentation files (the -- 13 | -- "Software"), to deal in the Software without restriction, including -- 14 | -- without limitation the rights to use, copy, modify, merge, publish, -- 15 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 16 | -- permit persons to whom the Software is furnished to do so, subject to -- 17 | -- the following conditions: -- 18 | -- -- 19 | -- The above copyright notice and this permission notice shall be -- 20 | -- included in all copies or substantial portions of the Software. -- 21 | -- -- 22 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 23 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 24 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 25 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 26 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 27 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 28 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 29 | ------------------------------------------------------------------------------ 30 | 31 | with Ada.Text_IO; use Ada.Text_IO; 32 | 33 | package body Wavefile_Benchmarking.Statistics is 34 | 35 | -------------------------- 36 | -- Calculate_Statistics -- 37 | -------------------------- 38 | 39 | procedure Calculate_Statistics 40 | (Raw_Info : Wavefile_Benchmark_Infos; 41 | Results : out Wavefile_Benchmark_Statistics) 42 | is 43 | Total : Wavefile_Benchmark_kHz := (0.0, 0.0); 44 | Res : Wavefile_Benchmark_Statistics renames Results; 45 | begin 46 | for R of Raw_Info loop 47 | for B in Wavefile_Benchmark_Routine loop 48 | if Res.Max (B) < R (B) then 49 | Res.Max (B) := R (B); 50 | end if; 51 | 52 | if Res.Min (B) > R (B) then 53 | Res.Min (B) := R (B); 54 | end if; 55 | 56 | Total (B) := Total (B) + R (B); 57 | end loop; 58 | end loop; 59 | 60 | for B in Wavefile_Benchmark_Routine loop 61 | Res.Avg (B) := Total (B) / Float (Raw_Info'Length); 62 | end loop; 63 | end Calculate_Statistics; 64 | 65 | ------------- 66 | -- Display -- 67 | ------------- 68 | 69 | procedure Display (Stats : Wavefile_Benchmark_Statistics) is 70 | package F_IO is new Ada.Text_IO.Float_IO (Float); 71 | begin 72 | for B in Stats.Avg'Range loop 73 | Put ("Average Perf. " & B'Image & ": "); 74 | F_IO.Put (Item => Stats.Avg (B), 75 | Fore => 5, Aft => 4, Exp => 0); 76 | Put (" kHz (per channel and per 16-bit sample)"); 77 | New_Line; 78 | end loop; 79 | for B in Stats.Max'Range loop 80 | Put ("Max Perf. " & B'Image & ": "); 81 | F_IO.Put (Item => Stats.Max (B), 82 | Fore => 5, Aft => 4, Exp => 0); 83 | Put (" kHz (per channel and per 16-bit sample)"); 84 | New_Line; 85 | end loop; 86 | for B in Stats.Min'Range loop 87 | Put ("Min Perf. " & B'Image & ": "); 88 | F_IO.Put (Item => Stats.Min (B), 89 | Fore => 5, Aft => 4, Exp => 0); 90 | Put (" kHz (per channel and per 16-bit sample)"); 91 | New_Line; 92 | end loop; 93 | end Display; 94 | 95 | end Wavefile_Benchmarking.Statistics; 96 | -------------------------------------------------------------------------------- /test/simple_benchmarking/src/simple_benchmarking.adb: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- WAVEFILES -- 4 | -- -- 5 | -- Wavefile benchmarking -- 6 | -- -- 7 | -- The MIT License (MIT) -- 8 | -- -- 9 | -- Copyright (c) 2020 Gustavo A. Hoffmann -- 10 | -- -- 11 | -- Permission is hereby granted, free of charge, to any person obtaining -- 12 | -- a copy of this software and associated documentation files (the -- 13 | -- "Software"), to deal in the Software without restriction, including -- 14 | -- without limitation the rights to use, copy, modify, merge, publish, -- 15 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 16 | -- permit persons to whom the Software is furnished to do so, subject to -- 17 | -- the following conditions: -- 18 | -- -- 19 | -- The above copyright notice and this permission notice shall be -- 20 | -- included in all copies or substantial portions of the Software. -- 21 | -- -- 22 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 23 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 24 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 25 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 26 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 27 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 28 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 29 | ------------------------------------------------------------------------------ 30 | 31 | with Ada.Command_Line; use Ada.Command_Line; 32 | with Ada.Text_IO; use Ada.Text_IO; 33 | 34 | with System.Multiprocessors; 35 | with System.Multiprocessors.Dispatching_Domains; 36 | 37 | with Wavefile_Benchmarking; use Wavefile_Benchmarking; 38 | with Wavefile_Benchmarking.Statistics; use Wavefile_Benchmarking.Statistics; 39 | 40 | procedure Simple_Benchmarking is 41 | 42 | CPU_MHz : Float := 2650.0; 43 | 44 | Verbose : constant Boolean := True; 45 | 46 | Results : Wavefile_Benchmark_Infos (1 .. 5); 47 | 48 | task type Wavefile_Benchmark 49 | with CPU => 1 50 | is 51 | entry Finish (Res : out Wavefile_Benchmark_Infos); 52 | end Wavefile_Benchmark; 53 | 54 | task body Wavefile_Benchmark is 55 | Local_Results : Wavefile_Benchmark_Infos (Results'Range); 56 | begin 57 | if Verbose then 58 | Display_Current_CPU : declare 59 | use System.Multiprocessors; 60 | use System.Multiprocessors.Dispatching_Domains; 61 | begin 62 | Put_Line ("Current CPU : " & CPU_Range'Image (Get_CPU)); 63 | end Display_Current_CPU; 64 | end if; 65 | 66 | Benchm_CPU_Time (CPU_MHz, Local_Results); 67 | 68 | accept Finish (Res : out Wavefile_Benchmark_Infos) do 69 | Res := Local_Results; 70 | end Finish; 71 | end Wavefile_Benchmark; 72 | 73 | Benchmark_Using_Tasking : constant Boolean := False; 74 | 75 | begin 76 | if Argument_Count >= 1 then 77 | CPU_MHz := Float'Value (Argument (1)); 78 | end if; 79 | 80 | if Verbose then 81 | Put_Line ("Using CPU @ " & Float'Image (CPU_MHz) & " MHz"); 82 | end if; 83 | 84 | if Benchmark_Using_Tasking then 85 | declare 86 | Wav_Benchmark : Wavefile_Benchmark; 87 | begin 88 | Wav_Benchmark.Finish (Results); 89 | end; 90 | else 91 | Benchm_CPU_Time (CPU_MHz, Results); 92 | end if; 93 | 94 | Calc_Statistics : declare 95 | Stats : Wavefile_Benchmark_Statistics; 96 | begin 97 | Calculate_Statistics (Results, Stats); 98 | Display (Stats); 99 | end Calc_Statistics; 100 | 101 | end Simple_Benchmarking; 102 | -------------------------------------------------------------------------------- /test/simple_benchmarking/src/write_random_noise_wavefile.adb: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- WAVEFILES -- 4 | -- -- 5 | -- Wavefile benchmarking -- 6 | -- -- 7 | -- The MIT License (MIT) -- 8 | -- -- 9 | -- Copyright (c) 2020 Gustavo A. Hoffmann -- 10 | -- -- 11 | -- Permission is hereby granted, free of charge, to any person obtaining -- 12 | -- a copy of this software and associated documentation files (the -- 13 | -- "Software"), to deal in the Software without restriction, including -- 14 | -- without limitation the rights to use, copy, modify, merge, publish, -- 15 | -- distribute, sublicense, and / or sell copies of the Software, and to -- 16 | -- permit persons to whom the Software is furnished to do so, subject to -- 17 | -- the following conditions: -- 18 | -- -- 19 | -- The above copyright notice and this permission notice shall be -- 20 | -- included in all copies or substantial portions of the Software. -- 21 | -- -- 22 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- 23 | -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- 24 | -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- 25 | -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- 26 | -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- 27 | -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- 28 | -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 29 | ------------------------------------------------------------------------------ 30 | 31 | with Ada.Numerics.Float_Random; use Ada.Numerics.Float_Random; 32 | 33 | with Audio.Wavefiles; use Audio.Wavefiles; 34 | with Audio.Wavefiles.Data_Types; use Audio.Wavefiles.Data_Types; 35 | with Audio.Wavefiles.Generic_Float_PCM_IO; 36 | with Audio.RIFF.Wav.Formats; use Audio.RIFF.Wav.Formats; 37 | 38 | --------------------------------- 39 | -- Write_Random_Noise_Wavefile -- 40 | --------------------------------- 41 | 42 | procedure Write_Random_Noise_Wavefile is 43 | Wav_File_Name : constant String := "2ch_long_noise.wav"; 44 | Sample_Rate_Enum : constant Wav_Sample_Rate := Sample_Rate_44100; 45 | Num_Channels : constant Positive := 2; 46 | 47 | WF : Wavefile; 48 | begin 49 | WF.Set_Format_Of_Wavefile (Init (Bit_Depth => Bit_Depth_16, 50 | Sample_Rate => Sample_Rate_Enum, 51 | Number_Of_Channels => Num_Channels, 52 | Use_Float => False)); 53 | 54 | WF.Create (Out_File, Wav_File_Name); 55 | 56 | if WF.Is_Open then 57 | 58 | Write_Stereo_Random_Noise : declare 59 | package PCM_IO is new Audio.Wavefiles.Generic_Float_PCM_IO 60 | (PCM_Sample => Wav_Float_32, 61 | Channel_Range => Positive, 62 | PCM_MC_Sample => Wav_Buffer_Float_32); 63 | use PCM_IO; 64 | 65 | Sample_Rate : constant Float := 66 | Float (To_Positive (Sample_Rate_Enum)); 67 | Duration_In_Secs : constant := 240.0; 68 | Last_Sample : constant Positive 69 | := Positive (Sample_Rate * Duration_In_Secs); 70 | 71 | PCM_Buf : Wav_Buffer_Float_32 (1 .. Num_Channels); 72 | 73 | Gen : Generator; 74 | begin 75 | Reset (Gen); 76 | 77 | for Sample in 1 .. Last_Sample loop 78 | for Ch_Num in PCM_Buf'Range loop 79 | PCM_Buf (Ch_Num) := Wav_Float_32 (Random (Gen) * 1.95 - 1.0); 80 | end loop; 81 | Put (WF, PCM_Buf); 82 | end loop; 83 | end Write_Stereo_Random_Noise; 84 | 85 | WF.Close; 86 | end if; 87 | 88 | end Write_Random_Noise_Wavefile; 89 | --------------------------------------------------------------------------------