From deeb65293959a875d581db32eee1c4daaca3f1f9 Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Thu, 24 Sep 2009 13:45:43 +0100 Subject: [PATCH] fixed a seek bug in the flac reader; added a JucePlugin_TailLengthSeconds setting for plugins; made the colour class limit the HSV values that are passed into it --- build/macosx/Juce.xcodeproj/project.pbxproj | 2 +- .../demo/src/JucePluginCharacteristics.h | 6 +++++ .../wrapper/AU/juce_AU_Wrapper.mm | 2 +- .../wrapper/VST/juce_VST_Wrapper.cpp | 2 +- .../wrapper/juce_IncludeCharacteristics.h | 4 ++++ juce_amalgamated.cpp | 18 +++++++-------- juce_amalgamated.h | 23 ++++++++++++++++--- .../juce_FlacAudioFormat.cpp | 11 ++++----- src/gui/graphics/colour/juce_Colour.cpp | 7 ++++-- 9 files changed, 51 insertions(+), 24 deletions(-) diff --git a/build/macosx/Juce.xcodeproj/project.pbxproj b/build/macosx/Juce.xcodeproj/project.pbxproj index 9d108a2c4e..4083c83317 100644 --- a/build/macosx/Juce.xcodeproj/project.pbxproj +++ b/build/macosx/Juce.xcodeproj/project.pbxproj @@ -2100,12 +2100,12 @@ isa = PBXGroup; children = ( 84F1EB2410403709006A1807 /* juce_Colour.cpp */, + 84F1EB2A10403709006A1807 /* juce_Colour.h */, 84F1EB2510403709006A1807 /* juce_ColourGradient.cpp */, 84F1EB2610403709006A1807 /* juce_ColourGradient.h */, 84F1EB2710403709006A1807 /* juce_Colours.cpp */, 84F1EB2810403709006A1807 /* juce_Colours.h */, 84F1EB2910403709006A1807 /* juce_PixelFormats.h */, - 84F1EB2A10403709006A1807 /* juce_Colour.h */, ); name = colour; path = ../../src/gui/graphics/colour; diff --git a/extras/audio plugins/demo/src/JucePluginCharacteristics.h b/extras/audio plugins/demo/src/JucePluginCharacteristics.h index bceeaf4a24..362c42afd7 100644 --- a/extras/audio plugins/demo/src/JucePluginCharacteristics.h +++ b/extras/audio plugins/demo/src/JucePluginCharacteristics.h @@ -154,6 +154,12 @@ */ #define JucePlugin_SilenceInProducesSilenceOut 0 +/** If your plugin has a tail, you can set the length here and this information + will be passed on to the host. + (Not all formats/hosts might actually use this, though) +*/ +#define JucePlugin_TailLengthSeconds 0 + /** If set to 1, this hints that the host should ignore any keys that are pressed when the plugin has keyboard focus. If 0, then the host should still execute any shortcut keys that are pressed, even if the plugin does have focus. diff --git a/extras/audio plugins/wrapper/AU/juce_AU_Wrapper.mm b/extras/audio plugins/wrapper/AU/juce_AU_Wrapper.mm index bca7772b6d..5eba19a845 100644 --- a/extras/audio plugins/wrapper/AU/juce_AU_Wrapper.mm +++ b/extras/audio plugins/wrapper/AU/juce_AU_Wrapper.mm @@ -420,7 +420,7 @@ public: ComponentResult Version() { return JucePlugin_VersionCode; } bool SupportsTail() { return true; } - Float64 GetTailTime() { return 0; } + Float64 GetTailTime() { return (JucePlugin_TailLengthSeconds); } Float64 GetSampleRate() { diff --git a/extras/audio plugins/wrapper/VST/juce_VST_Wrapper.cpp b/extras/audio plugins/wrapper/VST/juce_VST_Wrapper.cpp index b3a32b53b2..1f0f055e56 100644 --- a/extras/audio plugins/wrapper/VST/juce_VST_Wrapper.cpp +++ b/extras/audio plugins/wrapper/VST/juce_VST_Wrapper.cpp @@ -419,7 +419,7 @@ public: #endif isSynth ((JucePlugin_IsSynth) != 0); - noTail ((JucePlugin_SilenceInProducesSilenceOut) != 0); + noTail (((JucePlugin_SilenceInProducesSilenceOut) != 0) && (JucePlugin_TailLengthSeconds <= 0)); setInitialDelay (filter->getLatencySamples()); programsAreChunks (true); diff --git a/extras/audio plugins/wrapper/juce_IncludeCharacteristics.h b/extras/audio plugins/wrapper/juce_IncludeCharacteristics.h index c11502483c..24736047b1 100644 --- a/extras/audio plugins/wrapper/juce_IncludeCharacteristics.h +++ b/extras/audio plugins/wrapper/juce_IncludeCharacteristics.h @@ -86,6 +86,10 @@ #error "You need to define the JucePlugin_EditorRequiresKeyboardFocus value in your JucePluginCharacteristics.h file!" #endif +#ifndef JucePlugin_TailLengthSeconds + #error "You need to define the JucePlugin_TailLengthSeconds value in your JucePluginCharacteristics.h file!" +#endif + #if ! (JucePlugin_Build_VST || JucePlugin_Build_AU || JucePlugin_Build_RTAS || JucePlugin_Build_Standalone) #error "You need to define at least one plugin format value in your JucePluginCharacteristics.h file!" #endif diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index e9988ec24f..fc09d06471 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -75095,13 +75095,14 @@ const Colour Colour::fromRGBAFloat (const uint8 red, return Colour (red, green, blue, alpha); } -static void convertHSBtoRGB (float h, const float s, float v, +static void convertHSBtoRGB (float h, float s, float v, uint8& r, uint8& g, uint8& b) throw() { + v = jlimit (0.0f, 1.0f, v); v *= 255.0f; const uint8 intV = (uint8) roundFloatToInt (v); - if (s == 0) + if (s <= 0) { r = intV; g = intV; @@ -75109,6 +75110,8 @@ static void convertHSBtoRGB (float h, const float s, float v, } else { + s = jmin (1.0f, s); + h = jlimit (0.0f, 1.0f, h); h = (h - floorf (h)) * 6.0f + 0.00001f; // need a small adjustment to compensate for rounding errors const float f = h - floorf (h); @@ -122969,11 +122972,10 @@ public: if (startSampleInFile < reservoirStart || startSampleInFile > reservoirStart + jmax (samplesInReservoir, 511)) { + samplesInReservoir = 0; + if (startSampleInFile >= (int) lengthInSamples) - { - samplesInReservoir = 0; break; - } // had some problems with flac crashing if the read pos is aligned more // accurately than this. Probably fixed in newer versions of the library, though. @@ -122983,12 +122985,10 @@ public: else { reservoirStart += samplesInReservoir; + samplesInReservoir = 0; + FLAC__stream_decoder_process_single (decoder); } - samplesInReservoir = 0; - - FLAC__stream_decoder_process_single (decoder); - if (samplesInReservoir == 0) break; } diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 9875ad7c94..8269fcf95a 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -25228,7 +25228,17 @@ public: /** Returns the timestamp associated with this message. - The units for the timestamp will be application-specific. + The exact meaning of this time and its units will vary, as messages are used in + a variety of different contexts. + + If you're getting the message from a midi file, this could be a time in seconds, or + a number of ticks - see MidiFile::convertTimestampTicksToSeconds(). + + If the message is being used in a MidiBuffer, it might indicate the number of + audio samples from the start of the buffer. + + If the message was created by a MidiInput, see MidiInputCallback::handleIncomingMidiMessage() + for details of the way that it initialises this value. @see setTimeStamp, addToTimeStamp */ @@ -25236,7 +25246,7 @@ public: /** Changes the message's associated timestamp. - The units for the timestamp will be application-specific. + The units for the timestamp will be application-specific - see the notes for getTimeStamp(). @see addToTimeStamp, getTimeStamp */ @@ -34425,6 +34435,8 @@ public: bool operator== (const AudioDeviceSetup& other) const; /** The name of the audio device used for output. + The name has to be one of the ones listed by the AudioDeviceManager's currently + selected device type. This may be the same as the input device. */ String outputDeviceName; @@ -34546,6 +34558,12 @@ public: */ const String getCurrentAudioDeviceType() const throw() { return currentDeviceType; } + /** Returns the currently active audio device type object. + Don't keep a copy of this pointer - it's owned by the device manager and could + change at any time. + */ + AudioIODeviceType* getCurrentDeviceTypeObject() const; + /** Changes the class of audio device being used. This switches between, e.g. ASIO and DirectSound. On the Mac you probably won't ever call @@ -34794,7 +34812,6 @@ private: void scanDevicesIfNeeded(); void deleteCurrentDevice(); double chooseBestSampleRate (double preferred) const; - AudioIODeviceType* getCurrentDeviceTypeObject() const; void insertDefaultDeviceNames (AudioDeviceSetup& setup) const; AudioIODeviceType* findType (const String& inputName, const String& outputName); diff --git a/src/audio/audio_file_formats/juce_FlacAudioFormat.cpp b/src/audio/audio_file_formats/juce_FlacAudioFormat.cpp index 84e0999251..4f3932f4f9 100644 --- a/src/audio/audio_file_formats/juce_FlacAudioFormat.cpp +++ b/src/audio/audio_file_formats/juce_FlacAudioFormat.cpp @@ -180,11 +180,10 @@ public: if (startSampleInFile < reservoirStart || startSampleInFile > reservoirStart + jmax (samplesInReservoir, 511)) { + samplesInReservoir = 0; + if (startSampleInFile >= (int) lengthInSamples) - { - samplesInReservoir = 0; break; - } // had some problems with flac crashing if the read pos is aligned more // accurately than this. Probably fixed in newer versions of the library, though. @@ -194,12 +193,10 @@ public: else { reservoirStart += samplesInReservoir; + samplesInReservoir = 0; + FLAC__stream_decoder_process_single (decoder); } - samplesInReservoir = 0; - - FLAC__stream_decoder_process_single (decoder); - if (samplesInReservoir == 0) break; } diff --git a/src/gui/graphics/colour/juce_Colour.cpp b/src/gui/graphics/colour/juce_Colour.cpp index 0bc21d9191..82248ff47b 100644 --- a/src/gui/graphics/colour/juce_Colour.cpp +++ b/src/gui/graphics/colour/juce_Colour.cpp @@ -119,13 +119,14 @@ const Colour Colour::fromRGBAFloat (const uint8 red, } //============================================================================== -static void convertHSBtoRGB (float h, const float s, float v, +static void convertHSBtoRGB (float h, float s, float v, uint8& r, uint8& g, uint8& b) throw() { + v = jlimit (0.0f, 1.0f, v); v *= 255.0f; const uint8 intV = (uint8) roundFloatToInt (v); - if (s == 0) + if (s <= 0) { r = intV; g = intV; @@ -133,6 +134,8 @@ static void convertHSBtoRGB (float h, const float s, float v, } else { + s = jmin (1.0f, s); + h = jlimit (0.0f, 1.0f, h); h = (h - floorf (h)) * 6.0f + 0.00001f; // need a small adjustment to compensate for rounding errors const float f = h - floorf (h);