mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Fixed some errors in the examples
This commit is contained in:
parent
69d5f16be0
commit
7035a40879
7 changed files with 13 additions and 25 deletions
|
|
@ -90,8 +90,7 @@ struct ConvolutionDemoDSP
|
||||||
auto selectedType = cabinetTypeParameter->getCurrentSelectedID();
|
auto selectedType = cabinetTypeParameter->getCurrentSelectedID();
|
||||||
auto assetName = (selectedType == 2 ? "guitar_amp.wav" : "cassette_recorder.wav");
|
auto assetName = (selectedType == 2 ? "guitar_amp.wav" : "cassette_recorder.wav");
|
||||||
|
|
||||||
std::unique_ptr<InputStream> assetInputStream (createAssetInputStream (assetName));
|
if (auto assetInputStream = createAssetInputStream (assetName))
|
||||||
if (assetInputStream != nullptr)
|
|
||||||
{
|
{
|
||||||
currentCabinetData.reset();
|
currentCabinetData.reset();
|
||||||
assetInputStream->readIntoMemoryBlock (currentCabinetData);
|
assetInputStream->readIntoMemoryBlock (currentCabinetData);
|
||||||
|
|
|
||||||
|
|
@ -335,7 +335,7 @@ private:
|
||||||
FileOutputStream outStream (fileToSave);
|
FileOutputStream outStream (fileToSave);
|
||||||
|
|
||||||
if (outStream.openedOk())
|
if (outStream.openedOk())
|
||||||
if (auto inStream = std::unique_ptr<InputStream> (createAssetInputStream ("juce_icon.png")))
|
if (auto inStream = createAssetInputStream ("juce_icon.png"))
|
||||||
outStream.writeFromInputStream (*inStream, -1);
|
outStream.writeFromInputStream (*inStream, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -195,10 +195,8 @@ public:
|
||||||
roomSizeSlider.setRange (0.0, 1.0);
|
roomSizeSlider.setRange (0.0, 1.0);
|
||||||
addAndMakeVisible (roomSizeSlider);
|
addAndMakeVisible (roomSizeSlider);
|
||||||
|
|
||||||
if (auto* assetStream = createAssetInputStream ("proaudio.path"))
|
if (auto fileStream = createAssetInputStream ("proaudio.path"))
|
||||||
{
|
{
|
||||||
std::unique_ptr<InputStream> fileStream (assetStream);
|
|
||||||
|
|
||||||
Path proAudioPath;
|
Path proAudioPath;
|
||||||
proAudioPath.loadPathFromStream (*fileStream);
|
proAudioPath.loadPathFromStream (*fileStream);
|
||||||
proAudioIcon.setPath (proAudioPath);
|
proAudioIcon.setPath (proAudioPath);
|
||||||
|
|
@ -411,13 +409,13 @@ private:
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
void loadNewSampleBinary (const void* data, int dataSize, const char* format)
|
void loadNewSampleBinary (const void* data, int dataSize, const char* format)
|
||||||
{
|
{
|
||||||
auto* soundBuffer = new MemoryInputStream (data, static_cast<std::size_t> (dataSize), false);
|
auto soundBuffer = std::make_unique<MemoryInputStream> (data, static_cast<std::size_t> (dataSize), false);
|
||||||
loadNewSample (soundBuffer, format);
|
loadNewSample (std::move (soundBuffer), format);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadNewSample (InputStream* soundBuffer, const char* format)
|
void loadNewSample (std::unique_ptr<InputStream> soundBuffer, const char* format)
|
||||||
{
|
{
|
||||||
std::unique_ptr<AudioFormatReader> formatReader (formatManager.findFormatForFileExtension (format)->createReaderFor (soundBuffer, true));
|
std::unique_ptr<AudioFormatReader> formatReader (formatManager.findFormatForFileExtension (format)->createReaderFor (soundBuffer.release(), true));
|
||||||
|
|
||||||
BigInteger midiNotes;
|
BigInteger midiNotes;
|
||||||
midiNotes.setRange (0, 126, true);
|
midiNotes.setRange (0, 126, true);
|
||||||
|
|
|
||||||
|
|
@ -272,9 +272,7 @@ public:
|
||||||
auto maxSize = static_cast<size_t> (roundToInt (getSampleRate() * (8192.0 / 44100.0)));
|
auto maxSize = static_cast<size_t> (roundToInt (getSampleRate() * (8192.0 / 44100.0)));
|
||||||
auto assetName = (type == 0 ? "Impulse1.wav" : "Impulse2.wav");
|
auto assetName = (type == 0 ? "Impulse1.wav" : "Impulse2.wav");
|
||||||
|
|
||||||
std::unique_ptr<InputStream> assetInputStream (createAssetInputStream (assetName));
|
if (auto assetInputStream = createAssetInputStream (assetName))
|
||||||
|
|
||||||
if (assetInputStream != nullptr)
|
|
||||||
{
|
{
|
||||||
currentCabinetData.reset();
|
currentCabinetData.reset();
|
||||||
assetInputStream->readIntoMemoryBlock (currentCabinetData);
|
assetInputStream->readIntoMemoryBlock (currentCabinetData);
|
||||||
|
|
|
||||||
|
|
@ -157,9 +157,9 @@ private:
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadNewSample (InputStream* soundBuffer, const char* format)
|
void loadNewSample (std::unique_ptr<InputStream> soundBuffer, const char* format)
|
||||||
{
|
{
|
||||||
std::unique_ptr<AudioFormatReader> formatReader (formatManager.findFormatForFileExtension (format)->createReaderFor (soundBuffer, true));
|
std::unique_ptr<AudioFormatReader> formatReader (formatManager.findFormatForFileExtension (format)->createReaderFor (soundBuffer.release(), true));
|
||||||
|
|
||||||
BigInteger midiNotes;
|
BigInteger midiNotes;
|
||||||
midiNotes.setRange (0, 126, true);
|
midiNotes.setRange (0, 126, true);
|
||||||
|
|
|
||||||
|
|
@ -2062,11 +2062,9 @@ public:
|
||||||
SamplerAudioProcessor()
|
SamplerAudioProcessor()
|
||||||
: AudioProcessor (BusesProperties().withOutput ("Output", AudioChannelSet::stereo(), true))
|
: AudioProcessor (BusesProperties().withOutput ("Output", AudioChannelSet::stereo(), true))
|
||||||
{
|
{
|
||||||
if (auto* asset = createAssetInputStream ("cello.wav"))
|
if (auto inputStream = createAssetInputStream ("cello.wav"))
|
||||||
{
|
{
|
||||||
std::unique_ptr<InputStream> inputStream (asset);
|
|
||||||
inputStream->readIntoMemoryBlock (mb);
|
inputStream->readIntoMemoryBlock (mb);
|
||||||
|
|
||||||
readerFactory.reset (new MemoryAudioFormatReaderFactory (mb.getData(), mb.getSize()));
|
readerFactory.reset (new MemoryAudioFormatReaderFactory (mb.getData(), mb.getSize()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -395,11 +395,8 @@ public:
|
||||||
|
|
||||||
setInterceptsMouseClicks (! hasBeenPurchased, ! hasBeenPurchased);
|
setInterceptsMouseClicks (! hasBeenPurchased, ! hasBeenPurchased);
|
||||||
|
|
||||||
if (auto* assetStream = createAssetInputStream (String ("Purchases/" + String (imageResourceName)).toRawUTF8()))
|
if (auto fileStream = createAssetInputStream (String ("Purchases/" + String (imageResourceName)).toRawUTF8()))
|
||||||
{
|
|
||||||
std::unique_ptr<InputStream> fileStream (assetStream);
|
|
||||||
avatar = PNGImageFormat().decodeImage (*fileStream);
|
avatar = PNGImageFormat().decodeImage (*fileStream);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
|
|
@ -569,10 +566,8 @@ private:
|
||||||
{
|
{
|
||||||
auto assetName = "Purchases/" + soundNames[idx] + String (phraseListBox.getSelectedRow()) + ".ogg";
|
auto assetName = "Purchases/" + soundNames[idx] + String (phraseListBox.getSelectedRow()) + ".ogg";
|
||||||
|
|
||||||
if (auto* assetStream = createAssetInputStream (assetName.toRawUTF8()))
|
if (auto fileStream = createAssetInputStream (assetName.toRawUTF8()))
|
||||||
{
|
{
|
||||||
std::unique_ptr<InputStream> fileStream (assetStream);
|
|
||||||
|
|
||||||
currentPhraseData.reset();
|
currentPhraseData.reset();
|
||||||
fileStream->readIntoMemoryBlock (currentPhraseData);
|
fileStream->readIntoMemoryBlock (currentPhraseData);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue