Skip to content

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

Fix compilation errors on older macOS versions.

Peter Sobot5c128e4d038f
diff --git a/pedalboard/ExternalPlugin.h b/pedalboard/ExternalPlugin.h
index 1fdaa9b..08990a1 100644
--- a/pedalboard/ExternalPlugin.h
+++ b/pedalboard/ExternalPlugin.h
@@ -319,15 +319,15 @@ public:
// Use the provided plugin name to disambiguate:
if (pluginName) {
for (int i = 0; i < typesFound.size(); i++) {
- if (typesFound[i]->name.toStdString() == pluginName.value()) {
+ if (typesFound[i]->name.toStdString() == *pluginName) {
foundPluginDescription = *typesFound[i];
break;
}
}
if (foundPluginDescription.name.isEmpty()) {
- errorMessage += ", and the provided plugin_name \"" +
- pluginName.value() + "\" matched no plugins. ";
+ errorMessage += ", and the provided plugin_name \"" + *pluginName +
+ "\" matched no plugins. ";
}
} else {
errorMessage += ". ";
diff --git a/pedalboard/io/AudioFileInit.h b/pedalboard/io/AudioFileInit.h
index ef6333e..2a518db 100644
--- a/pedalboard/io/AudioFileInit.h
+++ b/pedalboard/io/AudioFileInit.h
@@ -99,7 +99,7 @@ inline void init_audio_file(py::module &m) {
}
return std::make_shared<WriteableAudioFile>(
- filename, sampleRate.value(), numChannels, bitDepth, quality);
+ filename, *sampleRate, numChannels, bitDepth, quality);
} else {
throw py::type_error("AudioFile instances can only be opened in "
"read mode (\"r\") or write mode (\"w\").");
@@ -146,7 +146,7 @@ inline void init_audio_file(py::module &m) {
}
return std::make_shared<WriteableAudioFile>(
- format.value_or(""), std::move(stream), sampleRate.value(),
+ format.value_or(""), std::move(stream), *sampleRate,
numChannels, bitDepth, quality);
} else {
throw py::type_error("AudioFile instances can only be opened in "
diff --git a/pedalboard/io/ReadableAudioFile.h b/pedalboard/io/ReadableAudioFile.h
index fe9fe53..cf86aab 100644
--- a/pedalboard/io/ReadableAudioFile.h
+++ b/pedalboard/io/ReadableAudioFile.h
@@ -110,8 +110,7 @@ public:
if (reader && reader->getFormatName() == "MP3 file") {
bool fileLooksLikeAnMP3 = false;
if (auto filename = getPythonInputStream()->getFilename()) {
- fileLooksLikeAnMP3 =
- juce::File(filename.value()).hasFileExtension("mp3");
+ fileLooksLikeAnMP3 = juce::File(*filename).hasFileExtension("mp3");
}
if (!fileLooksLikeAnMP3) {
diff --git a/pedalboard/io/WriteableAudioFile.h b/pedalboard/io/WriteableAudioFile.h
index 0b58a72..fc70868 100644
--- a/pedalboard/io/WriteableAudioFile.h
+++ b/pedalboard/io/WriteableAudioFile.h
@@ -227,7 +227,7 @@ public:
// if the stream name doesn't start with a slash.
juce::File file(
juce::String(juce::File::getSeparatorString()).toStdString() +
- "dummy-stream-filename-" + streamName.value());
+ "dummy-stream-filename-" + *streamName);
extension = file.getFileExtension().toStdString();
}
@@ -237,7 +237,7 @@ public:
if (pythonOutputStream->getFilename()) {
throw std::domain_error("Unable to detect audio format to use for "
"file-like object with filename: " +
- pythonOutputStream->getFilename().value());
+ *(pythonOutputStream->getFilename()));
} else {
throw std::domain_error(
"Provided format argument (\"" + filename +
@@ -275,9 +275,9 @@ public:
// Normalize the input to a string here, as we need to do parsing anyways:
std::string qualityString;
if (qualityInput) {
- if (auto *q = std::get_if<std::string>(&qualityInput.value())) {
+ if (auto *q = std::get_if<std::string>(&(*qualityInput))) {
qualityString = *q;
- } else if (auto *q = std::get_if<float>(&qualityInput.value())) {
+ } else if (auto *q = std::get_if<float>(&(*qualityInput))) {
if (isInteger(*q)) {
qualityString = std::to_string((int)*q);
} else {
@@ -723,7 +723,7 @@ inline void init_writeable_audio_file(py::module &m) {
"argument to be provided.");
}
return std::make_shared<WriteableAudioFile>(
- filename, sampleRate.value(), numChannels, bitDepth, quality);
+ filename, *sampleRate, numChannels, bitDepth, quality);
},
py::arg("cls"), py::arg("filename"),
py::arg("samplerate") = py::none(), py::arg("num_channels") = 1,
@@ -758,7 +758,7 @@ inline void init_writeable_audio_file(py::module &m) {
}
return std::make_shared<WriteableAudioFile>(
- format.value_or(""), std::move(stream), sampleRate.value(),
+ format.value_or(""), std::move(stream), *sampleRate,
numChannels, bitDepth, quality);
},
py::arg("cls"), py::arg("file_like"),
@@ -851,7 +851,7 @@ inline void init_writeable_audio_file(py::module &m) {
ss << " samplerate=" << file.getSampleRate();
ss << " num_channels=" << file.getNumChannels();
if (file.getQuality()) {
- ss << " quality=\"" << file.getQuality().value() << "\"";
+ ss << " quality=\"" << *file.getQuality() << "\"";
}
ss << " file_dtype=" << file.getFileDatatype();
}