๐ ๐ A Python library for audio.
C audioaudio-processingaudio-productionaudio-researchaudio-unitaugmentationjucemachine-learningpybind11pythonvst3vst3-host
Add tests for writing unsupported formats.
Peter Sobota883693f0604
diff --git a/.github/workflows/all.yml b/.github/workflows/all.ymlindex d87c281..43e28b7 100644--- a/.github/workflows/all.yml+++ b/.github/workflows/all.yml@@ -59,8 +59,8 @@ jobs:MINIMUM_COVERAGE_PERCENTAGE: 90strategy:matrix:- python-version: ['3.6'] # , '3.7', '3.8', '3.9', '3.10']- os: [windows-latest] # ubuntu-18.04, ubuntu-latest, windows-latest, macos-10.15, macos-latest]+ python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']+ os: [ubuntu-18.04, ubuntu-latest, windows-latest, macos-10.15, macos-latest]name: Test with Python ${{ matrix.python-version }} on ${{ matrix.os }}steps:- name: Set up Python ${{ matrix.python-version }}@@ -98,14 +98,14 @@ jobs:if: runner.os == 'Windows'- name: Build pedalboard locallyrun: python setup.py install- # - name: Install VSTs for testing- # env:- # GCS_ASSET_BUCKET_NAME: ${{ secrets.GCS_ASSET_BUCKET_NAME }}- # GCS_READER_SERVICE_ACCOUNT_KEY: ${{ secrets.GCS_READER_SERVICE_ACCOUNT_KEY }}- # run: python ./tests/download_test_plugins.py+ - name: Install VSTs for testing+ env:+ GCS_ASSET_BUCKET_NAME: ${{ secrets.GCS_ASSET_BUCKET_NAME }}+ GCS_READER_SERVICE_ACCOUNT_KEY: ${{ secrets.GCS_READER_SERVICE_ACCOUNT_KEY }}+ run: python ./tests/download_test_plugins.py- name: Run testsif: matrix.os != 'ubuntu-latest' || matrix.python-version != '3.6'- run: pytest -v --cov-report term --cov-fail-under=${{ env.MINIMUM_COVERAGE_PERCENTAGE }} --cov=pedalboard -k int32 -s+ run: pytest -v --cov-report term --cov-fail-under=${{ env.MINIMUM_COVERAGE_PERCENTAGE }} --cov=pedalboard- name: Run tests with coverage reportingif: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.6'run: |@@ -126,7 +126,6 @@ jobs:run-tests-with-address-sanitizer:runs-on: ${{ matrix.os }}- if: falsestrategy:matrix:python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']diff --git a/README.md b/README.mdindex a50b903..06de7c5 100644--- a/README.md+++ b/README.md@@ -11,7 +11,7 @@-`pedalboard` is a Python library for adding effects to audio. It supports a number of common audio effects out of the box, and also allows the use of [VST3ยฎ](https://www.steinberg.net/en/company/technologies/vst3.html) and [Audio Unit](https://en.wikipedia.org/wiki/Audio_Units) plugin formats for third-party effects. It was built by [Spotify's Audio Intelligence Lab](https://research.atspotify.com/audio-intelligence/) to enable using studio-quality audio effects from within Python and TensorFlow.+`pedalboard` is a Python library for manipulating audio: adding effects, reading, writing, and more. It supports a number of common audio effects out of the box, and also allows the use of [VST3ยฎ](https://www.steinberg.net/en/company/technologies/vst3.html) and [Audio Unit](https://en.wikipedia.org/wiki/Audio_Units) plugin formats for third-party effects. It was built by [Spotify's Audio Intelligence Lab](https://research.atspotify.com/audio-intelligence/) to enable using studio-quality audio effects from within Python and TensorFlow.Internally at Spotify, `pedalboard` is used for [data augmentation](https://en.wikipedia.org/wiki/Data_augmentation) to improve machine learning models. `pedalboard` also helps in the process of content creation, making it possible to add effects to audio without using a Digital Audio Workstation.diff --git a/pedalboard/io/AudioFile.h b/pedalboard/io/AudioFile.hindex c7abf00..0ed7cfb 100644--- a/pedalboard/io/AudioFile.h+++ b/pedalboard/io/AudioFile.h@@ -624,8 +624,6 @@ public:unsigned int bufferSize = DEFAULT_AUDIO_BUFFER_SIZE_FRAMES>bool writeConvertingTo(const InputType **channels, int numChannels,unsigned int numSamples) {- printf("in writeConvertingTo<%s, %s>(%d, %d)\n", typeid(TargetType).name(),- typeid(InputType).name(), numChannels, numSamples);std::vector<std::vector<TargetType>> targetTypeBuffers;targetTypeBuffers.resize(numChannels);@@ -688,18 +686,11 @@ public:template <typename SampleType>bool write(const SampleType **channels, int numChannels,unsigned int numSamples) {- printf("in write<%s>(%d, %d)\n", typeid(SampleType).name(), numChannels,- numSamples);if constexpr (std::is_integral<SampleType>::value) {if constexpr (std::is_same<SampleType, int>::value) {if (writer->isFloatingPoint()) {return writeConvertingTo<float>(channels, numChannels, numSamples);} else {- // When supplying int32 data, files come out inverted when writing on- // Windows! Try to get to the bottom of this:- printf("About to pass %d samples of %d-channel %s data to "- "writer->write\n",- numSamples, numChannels, typeid(SampleType).name());return writer->write(channels, numSamples);}} else {diff --git a/tests/test_io.py b/tests/test_io.pyindex ac4f65f..50296ec 100644--- a/tests/test_io.py+++ b/tests/test_io.py@@ -346,11 +346,7 @@ def test_basic_write(def test_write_exact_int32_to_16_bit_wav(tmp_path: pathlib.Path):- """- This test should fail on Windows, where it seems that passing int32 sample- data to WriteableAudioFile#write will invert (!?) the samples written.- """- filename = str(tmp_path / f"test.wav")+ filename = str(tmp_path / "test.wav")original = np.array([1, 2, 3, -1, -2, -3]).astype(np.int32)signal = (original << 16).astype(np.int32)@@ -367,7 +363,7 @@ def test_write_exact_int32_to_16_bit_wav(tmp_path: pathlib.Path):def test_read_16_bit_wav_matches_stdlib(tmp_path: pathlib.Path):- filename = str(tmp_path / f"test-16bit.wav")+ filename = str(tmp_path / "test-16bit.wav")original = np.array([1, 2, 3, -1, -2, -3]).astype(np.int16)signal = original.astype(np.int32) << 16@@ -388,7 +384,7 @@ def test_read_16_bit_wav_matches_stdlib(tmp_path: pathlib.Path):def test_basic_write_int32_to_16_bit_wav(tmp_path: pathlib.Path):samplerate = 44100num_channels = 1- filename = str(tmp_path / f"test.wav")+ filename = str(tmp_path / "test.wav")original = np.linspace(0, 1, 11)# As per AES17: the integer value -(2^31) should never show up in the stream.@@ -438,3 +434,11 @@ def test_unusable_sample_rates(tmp_path: pathlib.Path, extension: str, sampleratwith pytest.raises(ValueError) as e:pedalboard.io.WriteableAudioFile(filename, samplerate=samplerate, num_channels=1)assert "44100" in str(e), "Expected exception to include details about supported sample rates."++[email protected]("dtype", [np.uint8, np.uint16, np.uint32, np.uint64])+def test_fail_to_write_unsigned(tmp_path: pathlib.Path, dtype):+ filename = str(tmp_path / "test.wav")+ with pytest.raises(TypeError):+ with pedalboard.io.WriteableAudioFile(filename, samplerate=44100) as af:+ af.write(np.array([1, 2, 3, 4], dtype=dtype))