/* * Copyright (C) 2020 Linux Studio Plugins Project * (C) 2020 Vladimir Sadovnikov * * This file is part of lsp-runtime-lib * Created on: 19 апр. 2020 г. * * lsp-runtime-lib is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * lsp-runtime-lib is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with lsp-runtime-lib. If not, see . */ #include #include #include #include #include #define BUF_SAMPLES 127 #define FRAMES 2048 /* Code to generate audio file #include #include #include #define FRAMES 2048 int main() { SF_INFO sf_info; SNDFILE *sf_obj; sf_info.frames = FRAMES; sf_info.samplerate = 48000; sf_info.channels = 2; sf_info.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16 | SF_ENDIAN_LITTLE; sf_info.sections = 0; sf_info.seekable = 0; // Open sound file if ((sf_obj = sf_open("pcm.wav", SFM_WRITE, &sf_info)) == NULL) return -1; float delta = (8 * M_PI) / FRAMES; float buf[2 * FRAMES]; float *dst = buf; for (size_t i=0; i(), BUF_SAMPLES); if (read < 0) { UTEST_ASSERT(read == -STATUS_EOF); break; } UTEST_ASSERT(buf.valid()); // Check contents int16_t *ptr = buf.data(); for (ssize_t i=0; i(), BUF_SAMPLES); if (read < 0) { UTEST_ASSERT(read == -STATUS_EOF); break; } UTEST_ASSERT(buf.valid()); // Check contents uint16_t *ptr = buf.data(); for (ssize_t i=0; i(), BUF_SAMPLES); if (read < 0) { UTEST_ASSERT(read == -STATUS_EOF); break; } UTEST_ASSERT(buf.valid()); // Check contents float *ptr = buf.data(); for (ssize_t i=0; i(), BUF_SAMPLES); if (read < 0) { UTEST_ASSERT(read == -STATUS_EOF); break; } UTEST_ASSERT(buf.valid()); off += read; } UTEST_ASSERT(is.close() == STATUS_OK); } UTEST_MAIN { test_read_src_f32("mm/f32.wav"); test_read_f32("mm/pcm.wav"); test_read_s16("mm/pcm.wav"); test_read_u16("mm/pcm.wav"); test_read_alaw("mm/alaw.wav"); } UTEST_END;