Skip to content

๐ŸŽ› ๐Ÿ”Š A Python library for audio.

Rename from Bitcrusher to Bitcrush.

Peter Sobot0c70a5ef5684
diff --git a/README.md b/README.md
index 114dbe8..3d3a6a0 100644
--- a/README.md
+++ b/README.md
@@ -24,7 +24,7 @@ Internally at Spotify, `pedalboard` is used for [data augmentation](https://en.w
- Spatial effects: `Convolution`, `Delay`, `Reverb`
- Pitch effects: `PitchShift`
- Lossy compression: `GSMFullRateCompressor`, `MP3Compressor`
- - Quality reduction: `Resample`
+ - Quality reduction: `Resample`, `Bitcrush`
- Supports VST3ยฎ plugins on macOS, Windows, and Linux (`pedalboard.load_plugin`)
- Supports Audio Units on macOS
- Strong thread-safety, memory usage, and speed guarantees
diff --git a/pedalboard/plugins/Bitcrusher.h b/pedalboard/plugins/Bitcrush.h
similarity index 82%
rename from pedalboard/plugins/Bitcrusher.h
rename to pedalboard/plugins/Bitcrush.h
index 909c5d1..022445c 100644
--- a/pedalboard/plugins/Bitcrusher.h
+++ b/pedalboard/plugins/Bitcrush.h
@@ -19,7 +19,7 @@
#include <cmath>
namespace Pedalboard {
-template <typename SampleType> class Bitcrusher : public Plugin {
+template <typename SampleType> class Bitcrush : public Plugin {
public:
SampleType getBitDepth() const { return bitDepth; }
void setBitDepth(const SampleType value) {
@@ -73,27 +73,27 @@ private:
static constexpr int INNER_LOOP_DIMENSION = 16;
};
-inline void init_bitcrusher(py::module &m) {
- py::class_<Bitcrusher<float>, Plugin, std::shared_ptr<Bitcrusher<float>>>(
- m, "Bitcrusher",
+inline void init_bitcrush(py::module &m) {
+ py::class_<Bitcrush<float>, Plugin, std::shared_ptr<Bitcrush<float>>>(
+ m, "Bitcrush",
"A plugin that reduces the signal to a given bit depth, giving the audio "
"a lo-fi, digitized sound. Floating-point bit depths are supported.")
.def(py::init([](float bitDepth) {
- auto bitcrusher = std::make_unique<Bitcrusher<float>>();
- bitcrusher->setBitDepth(bitDepth);
- return bitcrusher;
+ auto bitcrush = std::make_unique<Bitcrush<float>>();
+ bitcrush->setBitDepth(bitDepth);
+ return bitcrush;
}),
py::arg("bit_depth") = 8)
.def("__repr__",
- [](const Bitcrusher<float> &plugin) {
+ [](const Bitcrush<float> &plugin) {
std::ostringstream ss;
- ss << "<pedalboard.Bitcrusher";
+ ss << "<pedalboard.Bitcrush";
ss << " bit_depth=" << plugin.getBitDepth();
ss << " at " << &plugin;
ss << ">";
return ss.str();
})
- .def_property("bit_depth", &Bitcrusher<float>::getBitDepth,
- &Bitcrusher<float>::setBitDepth);
+ .def_property("bit_depth", &Bitcrush<float>::getBitDepth,
+ &Bitcrush<float>::setBitDepth);
}
}; // namespace Pedalboard
diff --git a/pedalboard/python_bindings.cpp b/pedalboard/python_bindings.cpp
index 8bf2f67..d3a0bc0 100644
--- a/pedalboard/python_bindings.cpp
+++ b/pedalboard/python_bindings.cpp
@@ -39,7 +39,7 @@ namespace py = pybind11;
#include "plugin_templates/Resample.h"
#include "plugins/AddLatency.h"
-#include "plugins/Bitcrusher.h"
+#include "plugins/Bitcrush.h"
#include "plugins/Chain.h"
#include "plugins/Chorus.h"
#include "plugins/Compressor.h"
@@ -147,7 +147,7 @@ PYBIND11_MODULE(pedalboard_native, m) {
init_plugin_container(m);
// Publicly accessible plugins:
- init_bitcrusher(m);
+ init_bitcrush(m);
init_chorus(m);
init_compressor(m);
init_convolution(m);
diff --git a/tests/test_bitcrusher.py b/tests/test_bitcrush.py
similarity index 87%
rename from tests/test_bitcrusher.py
rename to tests/test_bitcrush.py
index 18cd7dd..fccf8e6 100644
--- a/tests/test_bitcrusher.py
+++ b/tests/test_bitcrush.py
@@ -17,7 +17,7 @@
import pytest
import numpy as np
-from pedalboard import Pedalboard, Bitcrusher
+from pedalboard import Pedalboard, Bitcrush
from .utils import generate_sine_at
@@ -25,10 +25,10 @@ from .utils import generate_sine_at
@pytest.mark.parametrize("fundamental_hz", [440, 880])
@pytest.mark.parametrize("sample_rate", [22050, 44100, 48000])
@pytest.mark.parametrize("num_channels", [1, 2])
-def test_bitcrusher(bit_depth: float, fundamental_hz: float, sample_rate: float, num_channels: int):
+def test_bitcrush(bit_depth: float, fundamental_hz: float, sample_rate: float, num_channels: int):
sine_wave = generate_sine_at(sample_rate, fundamental_hz, num_seconds=0.1, num_channels=num_channels)
- plugin = Bitcrusher(bit_depth)
+ plugin = Bitcrush(bit_depth)
output = plugin.process(sine_wave, sample_rate)
assert np.all(np.isfinite(output))