diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 6a7e1c0da0..37034f0d83 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -170,7 +170,19 @@ #elif defined (_MSC_VER) #define JUCE_MSVC 1 - #if _MSC_VER >= 1400 + #if _MSC_VER < 1500 + #define JUCE_VC8_OR_EARLIER 1 + + #if _MSC_VER < 1400 + #define JUCE_VC7_OR_EARLIER 1 + + #if _MSC_VER < 1300 + #define JUCE_VC6 1 + #endif + #endif + #endif + + #if ! JUCE_VC7_OR_EARLIER #define JUCE_USE_INTRINSICS 1 #endif #else @@ -4686,6 +4698,11 @@ class Expression::Helpers public: typedef ReferenceCountedObjectPtr TermPtr; + // This helper function is needed to work around VC6 scoping bugs + static const TermPtr& getTermFor (const Expression& exp) throw() { return exp.term; } + + friend class Expression::Term; // (also only needed as a VC6 workaround) + class Constant : public Term { public: @@ -4735,7 +4752,7 @@ public: try { - return c.getSymbolValue (mainSymbol, member).term->evaluate (c, recursionDepth); + return getTermFor (c.getSymbolValue (mainSymbol, member))->evaluate (c, recursionDepth); } catch (...) {} @@ -4765,7 +4782,7 @@ public: try { - return c != 0 && c->getSymbolValue (mainSymbol, member).term->referencesSymbol (s, c, recursionDepth); + return c != 0 && getTermFor (c->getSymbolValue (mainSymbol, member))->referencesSymbol (s, c, recursionDepth); } catch (EvaluationError&) { @@ -12105,11 +12122,11 @@ namespace NumberToStringConverters juce_wchar getDecimalPoint() { -#if JUCE_MSVC && _MSC_VER < 1400 + #if JUCE_VC7_OR_EARLIER static juce_wchar dp = std::_USE (std::locale(), std::numpunct ).decimal_point(); -#else + #else static juce_wchar dp = std::use_facet > (std::locale()).decimal_point(); -#endif + #endif return dp; } @@ -12141,15 +12158,15 @@ namespace NumberToStringConverters } else { -#if JUCE_WINDOWS - #if (JUCE_MSVC && _MSC_VER <= 1400) || JUCE_MINGW + #if JUCE_WINDOWS + #if JUCE_VC8_OR_EARLIER || JUCE_MINGW len = _snwprintf (buffer, numChars, L"%.9g", n); - #else + #else len = _snwprintf_s (buffer, numChars, _TRUNCATE, L"%.9g", n); - #endif -#else + #endif + #else len = swprintf (buffer, numChars, L"%.9g", n); -#endif + #endif return buffer; } } @@ -18994,7 +19011,7 @@ bool Value::operator!= (const Value& other) const return value != other.value && value->getValue() != other.getValue(); } -void Value::addListener (Listener* const listener) +void Value::addListener (ValueListener* const listener) { if (listener != 0) { @@ -19005,7 +19022,7 @@ void Value::addListener (Listener* const listener) } } -void Value::removeListener (Listener* const listener) +void Value::removeListener (ValueListener* const listener) { listeners.remove (listener); @@ -19016,7 +19033,7 @@ void Value::removeListener (Listener* const listener) void Value::callListeners() { Value v (*this); // (create a copy in case this gets deleted by a callback) - listeners.call (&Value::Listener::valueChanged, v); + listeners.call (&ValueListener::valueChanged, v); } OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const Value& value) @@ -25148,7 +25165,7 @@ void ResamplingAudioSource::createLowPass (const double frequencyRatio) const double proportionalRate = (frequencyRatio > 1.0) ? 0.5 / frequencyRatio : 0.5 * frequencyRatio; - const double n = 1.0 / tan (double_Pi * jmax (0.001, proportionalRate)); + const double n = 1.0 / std::tan (double_Pi * jmax (0.001, proportionalRate)); const double nSquared = n * n; const double c1 = 1.0 / (1.0 + std::sqrt (2.0) * n + nSquared); @@ -40045,7 +40062,9 @@ Component::Component (const String& name) Component::~Component() { + #if ! JUCE_VC6 // (access to private union not allowed in VC6) static_jassert (sizeof (flags) <= sizeof (componentFlags_)); + #endif componentListeners.call (&ComponentListener::componentBeingDeleted, *this); @@ -43714,12 +43733,12 @@ void Button::handleCommandMessage (int commandId) } } -void Button::addButtonListener (Listener* const newListener) +void Button::addButtonListener (ButtonListener* const newListener) { buttonListeners.add (newListener); } -void Button::removeButtonListener (Listener* const listener) +void Button::removeButtonListener (ButtonListener* const listener) { buttonListeners.remove (listener); } @@ -48105,12 +48124,12 @@ void ComboBox::mouseUp (const MouseEvent& e2) } } -void ComboBox::addListener (Listener* const listener) +void ComboBox::addListener (ComboBoxListener* const listener) { listeners.add (listener); } -void ComboBox::removeListener (Listener* const listener) +void ComboBox::removeListener (ComboBoxListener* const listener) { listeners.remove (listener); } @@ -48491,12 +48510,12 @@ KeyboardFocusTraverser* Label::createFocusTraverser() return new LabelKeyboardFocusTraverser(); } -void Label::addListener (Listener* const listener) +void Label::addListener (LabelListener* const listener) { listeners.add (listener); } -void Label::removeListener (Listener* const listener) +void Label::removeListener (LabelListener* const listener) { listeners.remove (listener); } @@ -49375,7 +49394,7 @@ void ListBox::setOutlineThickness (const int outlineThickness_) void ListBox::setHeaderComponent (Component* const newHeaderComponent) { - if (newHeaderComponent != headerComponent) + if (headerComponent != newHeaderComponent) { headerComponent = newHeaderComponent; @@ -49706,12 +49725,12 @@ void Slider::sendDragEnd() listeners.callChecked (checker, &SliderListener::sliderDragEnded, this); } -void Slider::addListener (Listener* const listener) +void Slider::addListener (SliderListener* const listener) { listeners.add (listener); } -void Slider::removeListener (Listener* const listener) +void Slider::removeListener (SliderListener* const listener) { listeners.remove (listener); } @@ -53140,7 +53159,7 @@ public: class TextEditor::TextHolderComponent : public Component, public Timer, - public Value::Listener + public ValueListener { public: TextHolderComponent (TextEditor& owner_) @@ -53541,12 +53560,12 @@ void TextEditor::escapePressed() postCommandMessage (TextEditorDefs::escapeKeyMessageId); } -void TextEditor::addListener (Listener* const newListener) +void TextEditor::addListener (TextEditorListener* const newListener) { listeners.add (newListener); } -void TextEditor::removeListener (Listener* const listenerToRemove) +void TextEditor::removeListener (TextEditorListener* const listenerToRemove) { listeners.remove (listenerToRemove); } @@ -54463,19 +54482,19 @@ void TextEditor::handleCommandMessage (const int commandId) switch (commandId) { case TextEditorDefs::textChangeMessageId: - listeners.callChecked (checker, &TextEditor::Listener::textEditorTextChanged, (TextEditor&) *this); + listeners.callChecked (checker, &TextEditorListener::textEditorTextChanged, (TextEditor&) *this); break; case TextEditorDefs::returnKeyMessageId: - listeners.callChecked (checker, &TextEditor::Listener::textEditorReturnKeyPressed, (TextEditor&) *this); + listeners.callChecked (checker, &TextEditorListener::textEditorReturnKeyPressed, (TextEditor&) *this); break; case TextEditorDefs::escapeKeyMessageId: - listeners.callChecked (checker, &TextEditor::Listener::textEditorEscapeKeyPressed, (TextEditor&) *this); + listeners.callChecked (checker, &TextEditorListener::textEditorEscapeKeyPressed, (TextEditor&) *this); break; case TextEditorDefs::focusLossMessageId: - listeners.callChecked (checker, &TextEditor::Listener::textEditorFocusLost, (TextEditor&) *this); + listeners.callChecked (checker, &TextEditorListener::textEditorFocusLost, (TextEditor&) *this); break; default: @@ -55511,7 +55530,7 @@ void Toolbar::itemDropped (const String&, Component* sourceComponent, int, int) tc->setState (Button::buttonNormal); } -void Toolbar::mouseDown (const MouseEvent& e) +void Toolbar::mouseDown (const MouseEvent&) { } @@ -63831,7 +63850,7 @@ public: repaint(); } - void buttonClicked (Button* button) + void buttonClicked (Button*) { owner.showExtraItemsMenu(); } @@ -72020,7 +72039,7 @@ END_JUCE_NAMESPACE BEGIN_JUCE_NAMESPACE class ChoicePropertyComponent::RemapperValueSource : public Value::ValueSource, - public Value::Listener + public ValueListener { public: RemapperValueSource (const Value& sourceValue_, const Array& mappings_) @@ -83564,7 +83583,7 @@ private: GradientEdgeTableRenderer& operator= (const GradientEdgeTableRenderer&); }; -namespace +namespace RenderingHelpers { forcedinline int safeModulo (int n, const int divisor) throw() { @@ -83585,8 +83604,8 @@ public: : destData (destData_), srcData (srcData_), extraAlpha (extraAlpha_ + 1), - xOffset (repeatPattern ? safeModulo (x, srcData_.width) - srcData_.width : x), - yOffset (repeatPattern ? safeModulo (y, srcData_.height) - srcData_.height : y) + xOffset (repeatPattern ? RenderingHelpers::safeModulo (x, srcData_.width) - srcData_.width : x), + yOffset (repeatPattern ? RenderingHelpers::safeModulo (y, srcData_.height) - srcData_.height : y) { } @@ -83828,8 +83847,8 @@ private: if (repeatPattern) { - loResX = safeModulo (loResX, srcData.width); - loResY = safeModulo (loResY, srcData.height); + loResX = RenderingHelpers::safeModulo (loResX, srcData.width); + loResY = RenderingHelpers::safeModulo (loResY, srcData.height); } if (betterQuality) @@ -86307,10 +86326,10 @@ bool DrawableComposite::Marker::operator!= (const DrawableComposite::Marker& oth return name != other.name || position != other.position; } -const char* const DrawableComposite::contentLeftMarkerName ("left"); -const char* const DrawableComposite::contentRightMarkerName ("right"); -const char* const DrawableComposite::contentTopMarkerName ("top"); -const char* const DrawableComposite::contentBottomMarkerName ("bottom"); +const char* const DrawableComposite::contentLeftMarkerName = "left"; +const char* const DrawableComposite::contentRightMarkerName = "right"; +const char* const DrawableComposite::contentTopMarkerName = "top"; +const char* const DrawableComposite::contentBottomMarkerName = "bottom"; const RelativeRectangle DrawableComposite::getContentArea() const { @@ -86746,7 +86765,7 @@ void DrawableComposite::ValueTreeWrapper::removeMarker (bool xAxis, const ValueT && state [nameProperty].toString() != contentRightMarkerName && state [nameProperty].toString() != contentTopMarkerName && state [nameProperty].toString() != contentBottomMarkerName) - return getMarkerList (xAxis).removeChild (state, undoManager); + getMarkerList (xAxis).removeChild (state, undoManager); } const Rectangle DrawableComposite::refreshFromValueTree (const ValueTree& tree, ImageProvider* imageProvider) @@ -87301,7 +87320,7 @@ Value DrawablePath::ValueTreeWrapper::Element::getControlPointValue (int index, void DrawablePath::ValueTreeWrapper::Element::setControlPoint (const int index, const RelativePoint& point, UndoManager* undoManager) { jassert (index >= 0 && index < getNumControlPoints()); - return state.setProperty (index == 0 ? point1 : (index == 1 ? point2 : point3), point.toString(), undoManager); + state.setProperty (index == 0 ? point1 : (index == 1 ? point2 : point3), point.toString(), undoManager); } const RelativePoint DrawablePath::ValueTreeWrapper::Element::getStartPoint() const @@ -95143,7 +95162,7 @@ public: return new LowLevelGraphicsSoftwareRenderer (Image (this)); } - SharedImage* clone() + Image::SharedImage* clone() { SoftwareSharedImage* s = new SoftwareSharedImage (format, width, height, false); memcpy (s->imageData, imageData, lineStride * height); @@ -95186,7 +95205,7 @@ public: return g; } - SharedImage* clone() + Image::SharedImage* clone() { return new SubsectionSharedImage (image->clone(), area); } @@ -238124,11 +238143,11 @@ __int64 juce_InterlockedCompareExchange64 (volatile __int64* value, __int64 newV CriticalSection::CriticalSection() throw() { // (just to check the MS haven't changed this structure and broken things...) -#if _MSC_VER >= 1400 - static_jassert (sizeof (CRITICAL_SECTION) <= sizeof (internal)); -#else + #if JUCE_VC7_OR_EARLIER static_jassert (sizeof (CRITICAL_SECTION) <= 24); -#endif + #else + static_jassert (sizeof (CRITICAL_SECTION) <= sizeof (internal)); + #endif InitializeCriticalSection ((CRITICAL_SECTION*) internal); } @@ -241663,7 +241682,7 @@ public: return new LowLevelGraphicsSoftwareRenderer (Image (this)); } - SharedImage* clone() + Image::SharedImage* clone() { WindowsBitmapImage* im = new WindowsBitmapImage (format, width, height, false); diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 270eb40c96..6ee4bb91e8 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -64,7 +64,7 @@ */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 52 -#define JUCE_BUILDNUMBER 91 +#define JUCE_BUILDNUMBER 92 /** Current Juce version number. @@ -208,7 +208,19 @@ #elif defined (_MSC_VER) #define JUCE_MSVC 1 - #if _MSC_VER >= 1400 + #if _MSC_VER < 1500 + #define JUCE_VC8_OR_EARLIER 1 + + #if _MSC_VER < 1400 + #define JUCE_VC7_OR_EARLIER 1 + + #if _MSC_VER < 1300 + #define JUCE_VC6 1 + #endif + #endif + #endif + + #if ! JUCE_VC7_OR_EARLIER #define JUCE_USE_INTRINSICS 1 #endif #else @@ -698,8 +710,20 @@ // Now we'll include any OS headers we need.. (at this point we are outside the Juce namespace). #if JUCE_MSVC - #if (defined(_MSC_VER) && (_MSC_VER <= 1200)) + #if JUCE_VC6 #pragma warning (disable: 4284 4786) // (spurious VC6 warnings) + + namespace std // VC6 doesn't have sqrt/sin/cos/tan/abs in std, so declare them here: + { + template Type abs (Type a) { if (a < 0) return -a; return a; } + template Type tan (Type a) { return static_cast (::tan (static_cast (a))); } + template Type sin (Type a) { return static_cast (::sin (static_cast (a))); } + template Type cos (Type a) { return static_cast (::cos (static_cast (a))); } + template Type sqrt (Type a) { return static_cast (::sqrt (static_cast (a))); } + template Type floor (Type a) { return static_cast (::floor (static_cast (a))); } + template Type ceil (Type a) { return static_cast (::ceil (static_cast (a))); } + template Type atan2 (Type a, Type b) { return static_cast (::atan2 (static_cast (a), static_cast (b))); } + } #endif #pragma warning (push) @@ -1035,7 +1059,7 @@ typedef unsigned int uint32; typedef int64 pointer_sized_int; /** An unsigned integer type that's guaranteed to be large enough to hold a pointer without truncating it. */ typedef uint64 pointer_sized_uint; -#elif _MSC_VER >= 1300 +#elif JUCE_MSVC && ! JUCE_VC6 /** A signed integer type that's guaranteed to be large enough to hold a pointer without truncating it. */ typedef _W64 int pointer_sized_int; /** An unsigned integer type that's guaranteed to be large enough to hold a pointer without truncating it. */ @@ -1114,22 +1138,26 @@ inline void swapVariables (Type& variable1, Type& variable2) variable2 = tempVal; } -/** Handy function for getting the number of elements in a simple const C array. +#if JUCE_VC6 + #define numElementsInArray(X) (sizeof((X)) / sizeof(0[X])) +#else + /** Handy function for getting the number of elements in a simple const C array. - E.g. - @code - static int myArray[] = { 1, 2, 3 }; + E.g. + @code + static int myArray[] = { 1, 2, 3 }; - int numElements = numElementsInArray (myArray) // returns 3 - @endcode -*/ -template -inline int numElementsInArray (Type (&array)[N]) -{ - (void) array; // (required to avoid a spurious warning in MS compilers) - sizeof (0[array]); // This line should cause an error if you pass an object with a user-defined subscript operator - return N; -} + int numElements = numElementsInArray (myArray) // returns 3 + @endcode + */ + template + inline int numElementsInArray (Type (&array)[N]) + { + (void) array; // (required to avoid a spurious warning in MS compilers) + sizeof (0[array]); // This line should cause an error if you pass an object with a user-defined subscript operator + return N; + } +#endif // Some useful maths functions that aren't always present with all compilers and build settings. @@ -1271,9 +1299,9 @@ inline int roundFloatToInt (const float value) throw() */ namespace TypeHelpers { -#if defined (_MSC_VER) && _MSC_VER <= 1400 + #if JUCE_VC8_OR_EARLIER #define PARAMETER_TYPE(a) a -#else + #else /** The ParameterType struct is used to find the best type to use when passing some kind of object as a parameter. @@ -1288,7 +1316,7 @@ namespace TypeHelpers */ template struct ParameterType { typedef const Type& type; }; -#if ! DOXYGEN + #if ! DOXYGEN template struct ParameterType { typedef Type& type; }; template struct ParameterType { typedef Type* type; }; template <> struct ParameterType { typedef char type; }; @@ -1304,13 +1332,13 @@ namespace TypeHelpers template <> struct ParameterType { typedef bool type; }; template <> struct ParameterType { typedef float type; }; template <> struct ParameterType { typedef double type; }; -#endif + #endif /** A helpful macro to simplify the use of the ParameterType template. @see ParameterType */ #define PARAMETER_TYPE(a) typename TypeHelpers::ParameterType::type -#endif + #endif } #endif // __JUCE_MATHSFUNCTIONS_JUCEHEADER__ @@ -4016,7 +4044,7 @@ template -inline bool operator== (const ScopedPointer& pointer1, const ObjectType* const pointer2) throw() +bool operator== (const ScopedPointer& pointer1, ObjectType* const pointer2) throw() { return static_cast (pointer1) == pointer2; } @@ -6785,7 +6813,7 @@ inline bool operator== (const ScopedPointer& pointer1, const ObjectT This can be handy for checking whether this is a null pointer. */ template -inline bool operator!= (const ScopedPointer& pointer1, const ObjectType* const pointer2) throw() +bool operator!= (const ScopedPointer& pointer1, ObjectType* const pointer2) throw() { return static_cast (pointer1) != pointer2; } @@ -12500,7 +12528,7 @@ template image; }; @@ -30099,6 +30133,240 @@ public: class NonConst; /**< Used as a template parameter for AudioData::Pointer. Indicates that the pointer can be used for non-const data. */ class Const; /**< Used as a template parameter for AudioData::Pointer. Indicates that the samples can only be used for const data.. */ + #ifndef DOXYGEN + + class BigEndian + { + public: + template static inline float getAsFloat (SampleFormatType& s) throw() { return s.getAsFloatBE(); } + template static inline void setAsFloat (SampleFormatType& s, float newValue) throw() { s.setAsFloatBE (newValue); } + template static inline int32 getAsInt32 (SampleFormatType& s) throw() { return s.getAsInt32BE(); } + template static inline void setAsInt32 (SampleFormatType& s, int32 newValue) throw() { s.setAsInt32BE (newValue); } + template static inline void copyFrom (DestType& dest, SourceType& source) throw() { dest.copyFromBE (source); } + enum { isBigEndian = 1 }; + }; + + class LittleEndian + { + public: + template static inline float getAsFloat (SampleFormatType& s) throw() { return s.getAsFloatLE(); } + template static inline void setAsFloat (SampleFormatType& s, float newValue) throw() { s.setAsFloatLE (newValue); } + template static inline int32 getAsInt32 (SampleFormatType& s) throw() { return s.getAsInt32LE(); } + template static inline void setAsInt32 (SampleFormatType& s, int32 newValue) throw() { s.setAsInt32LE (newValue); } + template static inline void copyFrom (DestType& dest, SourceType& source) throw() { dest.copyFromLE (source); } + enum { isBigEndian = 0 }; + }; + + #if JUCE_BIG_ENDIAN + class NativeEndian : public BigEndian {}; + #else + class NativeEndian : public LittleEndian {}; + #endif + + class Int8 + { + public: + inline Int8 (void* data_) throw() : data (static_cast (data_)) {} + + inline void advance() throw() { ++data; } + inline void skip (int numSamples) throw() { data += numSamples; } + inline float getAsFloatLE() const throw() { return (float) (*data * (1.0 / (1.0 + maxValue))); } + inline float getAsFloatBE() const throw() { return getAsFloatLE(); } + inline void setAsFloatLE (float newValue) throw() { *data = (int8) jlimit ((int) -maxValue, (int) maxValue, roundToInt (newValue * (1.0 + maxValue))); } + inline void setAsFloatBE (float newValue) throw() { setAsFloatLE (newValue); } + inline int32 getAsInt32LE() const throw() { return (int) (*data << 24); } + inline int32 getAsInt32BE() const throw() { return getAsInt32LE(); } + inline void setAsInt32LE (int newValue) throw() { *data = (int8) (newValue >> 24); } + inline void setAsInt32BE (int newValue) throw() { setAsInt32LE (newValue); } + inline void clear() throw() { *data = 0; } + inline void clearMultiple (int num) throw() { zeromem (data, num * bytesPerSample) ;} + template inline void copyFromLE (SourceType& source) throw() { setAsInt32LE (source.getAsInt32()); } + template inline void copyFromBE (SourceType& source) throw() { setAsInt32BE (source.getAsInt32()); } + inline void copyFromSameType (Int8& source) throw() { *data = *source.data; } + + int8* data; + enum { bytesPerSample = 1, maxValue = 0x7f, resolution = (1 << 24), isFloat = 0 }; + }; + + class UInt8 + { + public: + inline UInt8 (void* data_) throw() : data (static_cast (data_)) {} + + inline void advance() throw() { ++data; } + inline void skip (int numSamples) throw() { data += numSamples; } + inline float getAsFloatLE() const throw() { return (float) ((*data - 128) * (1.0 / (1.0 + maxValue))); } + inline float getAsFloatBE() const throw() { return getAsFloatLE(); } + inline void setAsFloatLE (float newValue) throw() { *data = (uint8) jlimit (0, 255, 128 + roundToInt (newValue * (1.0 + maxValue))); } + inline void setAsFloatBE (float newValue) throw() { setAsFloatLE (newValue); } + inline int32 getAsInt32LE() const throw() { return (int) ((*data - 128) << 24); } + inline int32 getAsInt32BE() const throw() { return getAsInt32LE(); } + inline void setAsInt32LE (int newValue) throw() { *data = (uint8) (128 + (newValue >> 24)); } + inline void setAsInt32BE (int newValue) throw() { setAsInt32LE (newValue); } + inline void clear() throw() { *data = 128; } + inline void clearMultiple (int num) throw() { memset (data, 128, num) ;} + template inline void copyFromLE (SourceType& source) throw() { setAsInt32LE (source.getAsInt32()); } + template inline void copyFromBE (SourceType& source) throw() { setAsInt32BE (source.getAsInt32()); } + inline void copyFromSameType (UInt8& source) throw() { *data = *source.data; } + + uint8* data; + enum { bytesPerSample = 1, maxValue = 0x7f, resolution = (1 << 24), isFloat = 0 }; + }; + + class Int16 + { + public: + inline Int16 (void* data_) throw() : data (static_cast (data_)) {} + + inline void advance() throw() { ++data; } + inline void skip (int numSamples) throw() { data += numSamples; } + inline float getAsFloatLE() const throw() { return (float) ((1.0 / (1.0 + maxValue)) * (int16) ByteOrder::swapIfBigEndian (*data)); } + inline float getAsFloatBE() const throw() { return (float) ((1.0 / (1.0 + maxValue)) * (int16) ByteOrder::swapIfLittleEndian (*data)); } + inline void setAsFloatLE (float newValue) throw() { *data = ByteOrder::swapIfBigEndian ((uint16) jlimit ((int16) -maxValue, (int16) maxValue, (int16) roundToInt (newValue * (1.0 + maxValue)))); } + inline void setAsFloatBE (float newValue) throw() { *data = ByteOrder::swapIfLittleEndian ((uint16) jlimit ((int16) -maxValue, (int16) maxValue, (int16) roundToInt (newValue * (1.0 + maxValue)))); } + inline int32 getAsInt32LE() const throw() { return (int32) (ByteOrder::swapIfBigEndian ((uint16) *data) << 16); } + inline int32 getAsInt32BE() const throw() { return (int32) (ByteOrder::swapIfLittleEndian ((uint16) *data) << 16); } + inline void setAsInt32LE (int32 newValue) throw() { *data = ByteOrder::swapIfBigEndian ((uint16) (newValue >> 16)); } + inline void setAsInt32BE (int32 newValue) throw() { *data = ByteOrder::swapIfLittleEndian ((uint16) (newValue >> 16)); } + inline void clear() throw() { *data = 0; } + inline void clearMultiple (int num) throw() { zeromem (data, num * bytesPerSample) ;} + template inline void copyFromLE (SourceType& source) throw() { setAsInt32LE (source.getAsInt32()); } + template inline void copyFromBE (SourceType& source) throw() { setAsInt32BE (source.getAsInt32()); } + inline void copyFromSameType (Int16& source) throw() { *data = *source.data; } + + uint16* data; + enum { bytesPerSample = 2, maxValue = 0x7fff, resolution = (1 << 16), isFloat = 0 }; + }; + + class Int24 + { + public: + inline Int24 (void* data_) throw() : data (static_cast (data_)) {} + + inline void advance() throw() { data += 3; } + inline void skip (int numSamples) throw() { data += 3 * numSamples; } + inline float getAsFloatLE() const throw() { return (float) (ByteOrder::littleEndian24Bit (data) * (1.0 / (1.0 + maxValue))); } + inline float getAsFloatBE() const throw() { return (float) (ByteOrder::bigEndian24Bit (data) * (1.0 / (1.0 + maxValue))); } + inline void setAsFloatLE (float newValue) throw() { ByteOrder::littleEndian24BitToChars (jlimit ((int) -maxValue, (int) maxValue, roundToInt (newValue * (1.0 + maxValue))), data); } + inline void setAsFloatBE (float newValue) throw() { ByteOrder::bigEndian24BitToChars (jlimit ((int) -maxValue, (int) maxValue, roundToInt (newValue * (1.0 + maxValue))), data); } + inline int32 getAsInt32LE() const throw() { return (int32) ByteOrder::littleEndian24Bit (data) << 8; } + inline int32 getAsInt32BE() const throw() { return (int32) ByteOrder::bigEndian24Bit (data) << 8; } + inline void setAsInt32LE (int32 newValue) throw() { ByteOrder::littleEndian24BitToChars (newValue >> 8, data); } + inline void setAsInt32BE (int32 newValue) throw() { ByteOrder::bigEndian24BitToChars (newValue >> 8, data); } + inline void clear() throw() { data[0] = 0; data[1] = 0; data[2] = 0; } + inline void clearMultiple (int num) throw() { zeromem (data, num * bytesPerSample) ;} + template inline void copyFromLE (SourceType& source) throw() { setAsInt32LE (source.getAsInt32()); } + template inline void copyFromBE (SourceType& source) throw() { setAsInt32BE (source.getAsInt32()); } + inline void copyFromSameType (Int24& source) throw() { data[0] = source.data[0]; data[1] = source.data[1]; data[2] = source.data[2]; } + + char* data; + enum { bytesPerSample = 3, maxValue = 0x7fffff, resolution = (1 << 8), isFloat = 0 }; + }; + + class Int32 + { + public: + inline Int32 (void* data_) throw() : data (static_cast (data_)) {} + + inline void advance() throw() { ++data; } + inline void skip (int numSamples) throw() { data += numSamples; } + inline float getAsFloatLE() const throw() { return (float) ((1.0 / (1.0 + maxValue)) * (int32) ByteOrder::swapIfBigEndian (*data)); } + inline float getAsFloatBE() const throw() { return (float) ((1.0 / (1.0 + maxValue)) * (int32) ByteOrder::swapIfLittleEndian (*data)); } + inline void setAsFloatLE (float newValue) throw() { *data = ByteOrder::swapIfBigEndian ((uint32) jlimit ((int) -maxValue, (int) maxValue, roundToInt (newValue * (1.0 + maxValue)))); } + inline void setAsFloatBE (float newValue) throw() { *data = ByteOrder::swapIfLittleEndian ((uint32) jlimit ((int) -maxValue, (int) maxValue, roundToInt (newValue * (1.0 + maxValue)))); } + inline int32 getAsInt32LE() const throw() { return (int32) ByteOrder::swapIfBigEndian (*data); } + inline int32 getAsInt32BE() const throw() { return (int32) ByteOrder::swapIfLittleEndian (*data); } + inline void setAsInt32LE (int32 newValue) throw() { *data = ByteOrder::swapIfBigEndian ((uint32) newValue); } + inline void setAsInt32BE (int32 newValue) throw() { *data = ByteOrder::swapIfLittleEndian ((uint32) newValue); } + inline void clear() throw() { *data = 0; } + inline void clearMultiple (int num) throw() { zeromem (data, num * bytesPerSample) ;} + template inline void copyFromLE (SourceType& source) throw() { setAsInt32LE (source.getAsInt32()); } + template inline void copyFromBE (SourceType& source) throw() { setAsInt32BE (source.getAsInt32()); } + inline void copyFromSameType (Int32& source) throw() { *data = *source.data; } + + uint32* data; + enum { bytesPerSample = 4, maxValue = 0x7fffffff, resolution = 1, isFloat = 0 }; + }; + + class Float32 + { + public: + inline Float32 (void* data_) throw() : data (static_cast (data_)) {} + + inline void advance() throw() { ++data; } + inline void skip (int numSamples) throw() { data += numSamples; } + #if JUCE_BIG_ENDIAN + inline float getAsFloatBE() const throw() { return *data; } + inline void setAsFloatBE (float newValue) throw() { *data = newValue; } + inline float getAsFloatLE() const throw() { union { uint32 asInt; float asFloat; } n; n.asInt = ByteOrder::swap (*(uint32*) data); return n.asFloat; } + inline void setAsFloatLE (float newValue) throw() { union { uint32 asInt; float asFloat; } n; n.asFloat = newValue; *(uint32*) data = ByteOrder::swap (n.asInt); } + #else + inline float getAsFloatLE() const throw() { return *data; } + inline void setAsFloatLE (float newValue) throw() { *data = newValue; } + inline float getAsFloatBE() const throw() { union { uint32 asInt; float asFloat; } n; n.asInt = ByteOrder::swap (*(uint32*) data); return n.asFloat; } + inline void setAsFloatBE (float newValue) throw() { union { uint32 asInt; float asFloat; } n; n.asFloat = newValue; *(uint32*) data = ByteOrder::swap (n.asInt); } + #endif + inline int32 getAsInt32LE() const throw() { return (int32) roundToInt (jlimit (-1.0f, 1.0f, getAsFloatLE()) * (1.0 + maxValue)); } + inline int32 getAsInt32BE() const throw() { return (int32) roundToInt (jlimit (-1.0f, 1.0f, getAsFloatBE()) * (1.0 + maxValue)); } + inline void setAsInt32LE (int32 newValue) throw() { setAsFloatLE ((float) (newValue * (1.0 / (1.0 + maxValue)))); } + inline void setAsInt32BE (int32 newValue) throw() { setAsFloatBE ((float) (newValue * (1.0 / (1.0 + maxValue)))); } + inline void clear() throw() { *data = 0; } + inline void clearMultiple (int num) throw() { zeromem (data, num * bytesPerSample) ;} + template inline void copyFromLE (SourceType& source) throw() { setAsFloatLE (source.getAsFloat()); } + template inline void copyFromBE (SourceType& source) throw() { setAsFloatBE (source.getAsFloat()); } + inline void copyFromSameType (Float32& source) throw() { *data = *source.data; } + + float* data; + enum { bytesPerSample = 4, maxValue = 0x7fffffff, resolution = (1 << 8), isFloat = 1 }; + }; + + class NonInterleaved + { + public: + inline NonInterleaved() throw() {} + inline NonInterleaved (const NonInterleaved&) throw() {} + inline NonInterleaved (const int) throw() {} + inline void copyFrom (const NonInterleaved&) throw() {} + template inline void advanceData (SampleFormatType& s) throw() { s.advance(); } + template inline void advanceDataBy (SampleFormatType& s, int numSamples) throw() { s.skip (numSamples); } + template inline void clear (SampleFormatType& s, int numSamples) throw() { s.clearMultiple (numSamples); } + template inline static int getNumBytesBetweenSamples (const SampleFormatType&) throw() { return SampleFormatType::bytesPerSample; } + + enum { isInterleavedType = 0, numInterleavedChannels = 1 }; + }; + + class Interleaved + { + public: + inline Interleaved() throw() : numInterleavedChannels (1) {} + inline Interleaved (const Interleaved& other) throw() : numInterleavedChannels (other.numInterleavedChannels) {} + inline Interleaved (const int numInterleavedChannels_) throw() : numInterleavedChannels (numInterleavedChannels_) {} + inline void copyFrom (const Interleaved& other) throw() { numInterleavedChannels = other.numInterleavedChannels; } + template inline void advanceData (SampleFormatType& s) throw() { s.skip (numInterleavedChannels); } + template inline void advanceDataBy (SampleFormatType& s, int numSamples) throw() { s.skip (numInterleavedChannels * numSamples); } + template inline void clear (SampleFormatType& s, int numSamples) throw() { while (--numSamples >= 0) { s.clear(); s.skip (numInterleavedChannels); } } + template inline int getNumBytesBetweenSamples (const SampleFormatType&) const throw() { return numInterleavedChannels * SampleFormatType::bytesPerSample; } + int numInterleavedChannels; + enum { isInterleavedType = 1 }; + }; + + class NonConst + { + public: + typedef void VoidType; + static inline void* toVoidPtr (VoidType* v) throw() { return v; } + enum { isConst = 0 }; + }; + + class Const + { + public: + typedef const void VoidType; + static inline void* toVoidPtr (VoidType* v) throw() { return const_cast (v); } + enum { isConst = 1 }; + }; + #endif + /** A pointer to a block of audio data with a particular encoding. @@ -30127,7 +30395,7 @@ public: typename Endianness, typename InterleavingType, typename Constness> - class Pointer : private InterleavingType + class Pointer { public: @@ -30147,22 +30415,22 @@ public: For non-interleaved data, use the other constructor. */ Pointer (typename Constness::VoidType* sourceData, int numInterleavedChannels) throw() - : InterleavingType (numInterleavedChannels), - data (Constness::toVoidPtr (sourceData)) + : data (Constness::toVoidPtr (sourceData)), + interleaving (numInterleavedChannels) { } /** Creates a copy of another pointer. */ Pointer (const Pointer& other) throw() - : InterleavingType (other), - data (other.data) + : data (other.data), + interleaving (other.interleaving) { } Pointer& operator= (const Pointer& other) throw() { data = other.data; - InterleavingType::copyFrom (other); + interleaving.copyFrom (other.interleaving); return *this; } @@ -30206,10 +30474,10 @@ public: inline Pointer& operator++() throw() { advance(); return *this; } /** Moves the pointer back to the previous sample. */ - inline Pointer& operator--() throw() { advanceDataBy (data, -1); return *this; } + inline Pointer& operator--() throw() { interleaving.advanceDataBy (data, -1); return *this; } /** Adds a number of samples to the pointer's position. */ - Pointer& operator+= (int samplesToJump) throw() { advanceDataBy (data, samplesToJump); return *this; } + Pointer& operator+= (int samplesToJump) throw() { interleaving.advanceDataBy (data, samplesToJump); return *this; } /** Writes a stream of samples into this pointer from another pointer. This will copy the specified number of samples, converting between formats appropriately. @@ -30260,7 +30528,7 @@ public: void clearSamples (int numSamples) const throw() { Pointer dest (*this); - dest.clear (dest.data, numSamples); + dest.interleaving.clear (dest.data, numSamples); } /** Returns true if the pointer is using a floating-point format. */ @@ -30276,7 +30544,7 @@ public: int getNumInterleavedChannels() const throw() { return (int) this->numInterleavedChannels; } /** Returns the number of bytes between the start address of each sample. */ - int getNumBytesBetweenSamples() const throw() { return InterleavingType::getNumBytesBetweenSamples (data); } + int getNumBytesBetweenSamples() const throw() { return interleaving.getNumBytesBetweenSamples (data); } /** Returns the accuracy of this format when represented as a 32-bit integer. This is the smallest number above 0 that can be represented in the sample format, converted to @@ -30291,8 +30559,10 @@ public: private: SampleFormat data; + InterleavingType interleaving; // annoyingly, making the interleaving type a superclass to take + // advantage of EBCO causes an internal compiler error in VC6.. - inline void advance() throw() { advanceData (data); } + inline void advance() throw() { interleaving.advanceData (data); } Pointer operator++ (int); // private to force you to use the more efficient pre-increment! Pointer operator-- (int); @@ -30365,241 +30635,6 @@ public: }; }; -#ifndef DOXYGEN - -class AudioData::BigEndian -{ -public: - template static inline float getAsFloat (SampleFormatType& s) throw() { return s.getAsFloatBE(); } - template static inline void setAsFloat (SampleFormatType& s, float newValue) throw() { s.setAsFloatBE (newValue); } - template static inline int32 getAsInt32 (SampleFormatType& s) throw() { return s.getAsInt32BE(); } - template static inline void setAsInt32 (SampleFormatType& s, int32 newValue) throw() { s.setAsInt32BE (newValue); } - template static inline void copyFrom (DestType& dest, SourceType& source) throw() { dest.copyFromBE (source); } - enum { isBigEndian = 1 }; -}; - -class AudioData::LittleEndian -{ -public: - template static inline float getAsFloat (SampleFormatType& s) throw() { return s.getAsFloatLE(); } - template static inline void setAsFloat (SampleFormatType& s, float newValue) throw() { s.setAsFloatLE (newValue); } - template static inline int32 getAsInt32 (SampleFormatType& s) throw() { return s.getAsInt32LE(); } - template static inline void setAsInt32 (SampleFormatType& s, int32 newValue) throw() { s.setAsInt32LE (newValue); } - template static inline void copyFrom (DestType& dest, SourceType& source) throw() { dest.copyFromLE (source); } - enum { isBigEndian = 0 }; -}; - -#if JUCE_BIG_ENDIAN - class AudioData::NativeEndian : public AudioData::BigEndian {}; -#else - class AudioData::NativeEndian : public AudioData::LittleEndian {}; -#endif - -class AudioData::Int8 -{ -public: - inline Int8 (void* data_) throw() : data (static_cast (data_)) {} - - inline void advance() throw() { ++data; } - inline void skip (int numSamples) throw() { data += numSamples; } - inline float getAsFloatLE() const throw() { return (float) (*data * (1.0 / (1.0 + maxValue))); } - inline float getAsFloatBE() const throw() { return getAsFloatLE(); } - inline void setAsFloatLE (float newValue) throw() { *data = (int8) jlimit ((int) -maxValue, (int) maxValue, roundToInt (newValue * (1.0 + maxValue))); } - inline void setAsFloatBE (float newValue) throw() { setAsFloatLE (newValue); } - inline int32 getAsInt32LE() const throw() { return (int) (*data << 24); } - inline int32 getAsInt32BE() const throw() { return getAsInt32LE(); } - inline void setAsInt32LE (int newValue) throw() { *data = (int8) (newValue >> 24); } - inline void setAsInt32BE (int newValue) throw() { setAsInt32LE (newValue); } - inline void clear() throw() { *data = 0; } - inline void clearMultiple (int num) throw() { zeromem (data, num * bytesPerSample) ;} - template inline void copyFromLE (SourceType& source) throw() { setAsInt32LE (source.getAsInt32()); } - template inline void copyFromBE (SourceType& source) throw() { setAsInt32BE (source.getAsInt32()); } - inline void copyFromSameType (Int8& source) throw() { *data = *source.data; } - - int8* data; - enum { bytesPerSample = 1, maxValue = 0x7f, resolution = (1 << 24), isFloat = 0 }; -}; - -class AudioData::UInt8 -{ -public: - inline UInt8 (void* data_) throw() : data (static_cast (data_)) {} - - inline void advance() throw() { ++data; } - inline void skip (int numSamples) throw() { data += numSamples; } - inline float getAsFloatLE() const throw() { return (float) ((*data - 128) * (1.0 / (1.0 + maxValue))); } - inline float getAsFloatBE() const throw() { return getAsFloatLE(); } - inline void setAsFloatLE (float newValue) throw() { *data = (uint8) jlimit (0, 255, 128 + roundToInt (newValue * (1.0 + maxValue))); } - inline void setAsFloatBE (float newValue) throw() { setAsFloatLE (newValue); } - inline int32 getAsInt32LE() const throw() { return (int) ((*data - 128) << 24); } - inline int32 getAsInt32BE() const throw() { return getAsInt32LE(); } - inline void setAsInt32LE (int newValue) throw() { *data = (uint8) (128 + (newValue >> 24)); } - inline void setAsInt32BE (int newValue) throw() { setAsInt32LE (newValue); } - inline void clear() throw() { *data = 128; } - inline void clearMultiple (int num) throw() { memset (data, 128, num) ;} - template inline void copyFromLE (SourceType& source) throw() { setAsInt32LE (source.getAsInt32()); } - template inline void copyFromBE (SourceType& source) throw() { setAsInt32BE (source.getAsInt32()); } - inline void copyFromSameType (UInt8& source) throw() { *data = *source.data; } - - uint8* data; - enum { bytesPerSample = 1, maxValue = 0x7f, resolution = (1 << 24), isFloat = 0 }; -}; - -class AudioData::Int16 -{ -public: - inline Int16 (void* data_) throw() : data (static_cast (data_)) {} - - inline void advance() throw() { ++data; } - inline void skip (int numSamples) throw() { data += numSamples; } - inline float getAsFloatLE() const throw() { return (float) ((1.0 / (1.0 + maxValue)) * (int16) ByteOrder::swapIfBigEndian (*data)); } - inline float getAsFloatBE() const throw() { return (float) ((1.0 / (1.0 + maxValue)) * (int16) ByteOrder::swapIfLittleEndian (*data)); } - inline void setAsFloatLE (float newValue) throw() { *data = ByteOrder::swapIfBigEndian ((uint16) jlimit ((int16) -maxValue, (int16) maxValue, (int16) roundToInt (newValue * (1.0 + maxValue)))); } - inline void setAsFloatBE (float newValue) throw() { *data = ByteOrder::swapIfLittleEndian ((uint16) jlimit ((int16) -maxValue, (int16) maxValue, (int16) roundToInt (newValue * (1.0 + maxValue)))); } - inline int32 getAsInt32LE() const throw() { return (int32) (ByteOrder::swapIfBigEndian ((uint16) *data) << 16); } - inline int32 getAsInt32BE() const throw() { return (int32) (ByteOrder::swapIfLittleEndian ((uint16) *data) << 16); } - inline void setAsInt32LE (int32 newValue) throw() { *data = ByteOrder::swapIfBigEndian ((uint16) (newValue >> 16)); } - inline void setAsInt32BE (int32 newValue) throw() { *data = ByteOrder::swapIfLittleEndian ((uint16) (newValue >> 16)); } - inline void clear() throw() { *data = 0; } - inline void clearMultiple (int num) throw() { zeromem (data, num * bytesPerSample) ;} - template inline void copyFromLE (SourceType& source) throw() { setAsInt32LE (source.getAsInt32()); } - template inline void copyFromBE (SourceType& source) throw() { setAsInt32BE (source.getAsInt32()); } - inline void copyFromSameType (Int16& source) throw() { *data = *source.data; } - - uint16* data; - enum { bytesPerSample = 2, maxValue = 0x7fff, resolution = (1 << 16), isFloat = 0 }; -}; - -class AudioData::Int24 -{ -public: - inline Int24 (void* data_) throw() : data (static_cast (data_)) {} - - inline void advance() throw() { data += 3; } - inline void skip (int numSamples) throw() { data += 3 * numSamples; } - inline float getAsFloatLE() const throw() { return (float) (ByteOrder::littleEndian24Bit (data) * (1.0 / (1.0 + maxValue))); } - inline float getAsFloatBE() const throw() { return (float) (ByteOrder::bigEndian24Bit (data) * (1.0 / (1.0 + maxValue))); } - inline void setAsFloatLE (float newValue) throw() { ByteOrder::littleEndian24BitToChars (jlimit ((int) -maxValue, (int) maxValue, roundToInt (newValue * (1.0 + maxValue))), data); } - inline void setAsFloatBE (float newValue) throw() { ByteOrder::bigEndian24BitToChars (jlimit ((int) -maxValue, (int) maxValue, roundToInt (newValue * (1.0 + maxValue))), data); } - inline int32 getAsInt32LE() const throw() { return (int32) ByteOrder::littleEndian24Bit (data) << 8; } - inline int32 getAsInt32BE() const throw() { return (int32) ByteOrder::bigEndian24Bit (data) << 8; } - inline void setAsInt32LE (int32 newValue) throw() { ByteOrder::littleEndian24BitToChars (newValue >> 8, data); } - inline void setAsInt32BE (int32 newValue) throw() { ByteOrder::bigEndian24BitToChars (newValue >> 8, data); } - inline void clear() throw() { data[0] = 0; data[1] = 0; data[2] = 0; } - inline void clearMultiple (int num) throw() { zeromem (data, num * bytesPerSample) ;} - template inline void copyFromLE (SourceType& source) throw() { setAsInt32LE (source.getAsInt32()); } - template inline void copyFromBE (SourceType& source) throw() { setAsInt32BE (source.getAsInt32()); } - inline void copyFromSameType (Int24& source) throw() { data[0] = source.data[0]; data[1] = source.data[1]; data[2] = source.data[2]; } - - char* data; - enum { bytesPerSample = 3, maxValue = 0x7fffff, resolution = (1 << 8), isFloat = 0 }; -}; - -class AudioData::Int32 -{ -public: - inline Int32 (void* data_) throw() : data (static_cast (data_)) {} - - inline void advance() throw() { ++data; } - inline void skip (int numSamples) throw() { data += numSamples; } - inline float getAsFloatLE() const throw() { return (float) ((1.0 / (1.0 + maxValue)) * (int32) ByteOrder::swapIfBigEndian (*data)); } - inline float getAsFloatBE() const throw() { return (float) ((1.0 / (1.0 + maxValue)) * (int32) ByteOrder::swapIfLittleEndian (*data)); } - inline void setAsFloatLE (float newValue) throw() { *data = ByteOrder::swapIfBigEndian ((uint32) jlimit ((int) -maxValue, (int) maxValue, roundToInt (newValue * (1.0 + maxValue)))); } - inline void setAsFloatBE (float newValue) throw() { *data = ByteOrder::swapIfLittleEndian ((uint32) jlimit ((int) -maxValue, (int) maxValue, roundToInt (newValue * (1.0 + maxValue)))); } - inline int32 getAsInt32LE() const throw() { return (int32) ByteOrder::swapIfBigEndian (*data); } - inline int32 getAsInt32BE() const throw() { return (int32) ByteOrder::swapIfLittleEndian (*data); } - inline void setAsInt32LE (int32 newValue) throw() { *data = ByteOrder::swapIfBigEndian ((uint32) newValue); } - inline void setAsInt32BE (int32 newValue) throw() { *data = ByteOrder::swapIfLittleEndian ((uint32) newValue); } - inline void clear() throw() { *data = 0; } - inline void clearMultiple (int num) throw() { zeromem (data, num * bytesPerSample) ;} - template inline void copyFromLE (SourceType& source) throw() { setAsInt32LE (source.getAsInt32()); } - template inline void copyFromBE (SourceType& source) throw() { setAsInt32BE (source.getAsInt32()); } - inline void copyFromSameType (Int32& source) throw() { *data = *source.data; } - - uint32* data; - enum { bytesPerSample = 4, maxValue = 0x7fffffff, resolution = 1, isFloat = 0 }; -}; - -class AudioData::Float32 -{ -public: - inline Float32 (void* data_) throw() : data (static_cast (data_)) {} - - inline void advance() throw() { ++data; } - inline void skip (int numSamples) throw() { data += numSamples; } - #if JUCE_BIG_ENDIAN - inline float getAsFloatBE() const throw() { return *data; } - inline void setAsFloatBE (float newValue) throw() { *data = newValue; } - inline float getAsFloatLE() const throw() { union { uint32 asInt; float asFloat; } n; n.asInt = ByteOrder::swap (*(uint32*) data); return n.asFloat; } - inline void setAsFloatLE (float newValue) throw() { union { uint32 asInt; float asFloat; } n; n.asFloat = newValue; *(uint32*) data = ByteOrder::swap (n.asInt); } - #else - inline float getAsFloatLE() const throw() { return *data; } - inline void setAsFloatLE (float newValue) throw() { *data = newValue; } - inline float getAsFloatBE() const throw() { union { uint32 asInt; float asFloat; } n; n.asInt = ByteOrder::swap (*(uint32*) data); return n.asFloat; } - inline void setAsFloatBE (float newValue) throw() { union { uint32 asInt; float asFloat; } n; n.asFloat = newValue; *(uint32*) data = ByteOrder::swap (n.asInt); } - #endif - inline int32 getAsInt32LE() const throw() { return (int32) roundToInt (jlimit (-1.0f, 1.0f, getAsFloatLE()) * (1.0 + maxValue)); } - inline int32 getAsInt32BE() const throw() { return (int32) roundToInt (jlimit (-1.0f, 1.0f, getAsFloatBE()) * (1.0 + maxValue)); } - inline void setAsInt32LE (int32 newValue) throw() { setAsFloatLE ((float) (newValue * (1.0 / (1.0 + maxValue)))); } - inline void setAsInt32BE (int32 newValue) throw() { setAsFloatBE ((float) (newValue * (1.0 / (1.0 + maxValue)))); } - inline void clear() throw() { *data = 0; } - inline void clearMultiple (int num) throw() { zeromem (data, num * bytesPerSample) ;} - template inline void copyFromLE (SourceType& source) throw() { setAsFloatLE (source.getAsFloat()); } - template inline void copyFromBE (SourceType& source) throw() { setAsFloatBE (source.getAsFloat()); } - inline void copyFromSameType (Float32& source) throw() { *data = *source.data; } - - float* data; - enum { bytesPerSample = 4, maxValue = 0x7fffffff, resolution = (1 << 8), isFloat = 1 }; -}; - -class AudioData::NonInterleaved -{ -public: - inline NonInterleaved() throw() {} - inline NonInterleaved (const NonInterleaved&) throw() {} - inline NonInterleaved (const int) throw() {} - inline void copyFrom (const NonInterleaved&) throw() {} - template inline void advanceData (SampleFormatType& s) throw() { s.advance(); } - template inline void advanceDataBy (SampleFormatType& s, int numSamples) throw() { s.skip (numSamples); } - template inline void clear (SampleFormatType& s, int numSamples) throw() { s.clearMultiple (numSamples); } - template inline static int getNumBytesBetweenSamples (const SampleFormatType&) throw() { return SampleFormatType::bytesPerSample; } - - enum { isInterleavedType = 0, numInterleavedChannels = 1 }; -}; - -class AudioData::Interleaved -{ -public: - inline Interleaved() throw() : numInterleavedChannels (1) {} - inline Interleaved (const Interleaved& other) throw() : numInterleavedChannels (other.numInterleavedChannels) {} - inline Interleaved (const int numInterleavedChannels_) throw() : numInterleavedChannels (numInterleavedChannels_) {} - inline void copyFrom (const Interleaved& other) throw() { numInterleavedChannels = other.numInterleavedChannels; } - template inline void advanceData (SampleFormatType& s) throw() { s.skip (numInterleavedChannels); } - template inline void advanceDataBy (SampleFormatType& s, int numSamples) throw() { s.skip (numInterleavedChannels * numSamples); } - template inline void clear (SampleFormatType& s, int numSamples) throw() { while (--numSamples >= 0) { s.clear(); s.skip (numInterleavedChannels); } } - template inline int getNumBytesBetweenSamples (const SampleFormatType&) const throw() { return numInterleavedChannels * SampleFormatType::bytesPerSample; } - int numInterleavedChannels; - enum { isInterleavedType = 1 }; -}; - -class AudioData::NonConst -{ -public: - typedef void VoidType; - static inline void* toVoidPtr (VoidType* v) throw() { return v; } - enum { isConst = 0 }; -}; - -class AudioData::Const -{ -public: - typedef const void VoidType; - static inline void* toVoidPtr (VoidType* v) throw() { return const_cast (v); } - enum { isConst = 1 }; -}; - -#endif - /** A set of routines to convert buffers of 32-bit floating point data to and from various integer formats. @@ -31569,8 +31604,10 @@ public: */ bool write (const float** data, int numSamples); + /** @internal */ + class Buffer; // (only public for VC6 compatibility) + private: - class Buffer; friend class ScopedPointer; ScopedPointer buffer; }; @@ -31621,6 +31658,7 @@ protected: private: String formatName; + friend class ThreadedWriter; AudioFormatWriter (const AudioFormatWriter&); AudioFormatWriter& operator= (const AudioFormatWriter&); @@ -32076,8 +32114,11 @@ public: */ void ejectDisk(); - static const int framesPerSecond = 75; - static const int samplesPerFrame = 44100 / framesPerSecond; + enum + { + framesPerSecond = 75, + samplesPerFrame = 44100 / framesPerSecond + }; juce_UseDebuggingNewOperator @@ -35776,6 +35817,10 @@ private: #endif // __JUCE_TOOLTIPWINDOW_JUCEHEADER__ /*** End of inlined file: juce_TooltipWindow.h ***/ +#if JUCE_VC6 + #define Listener ButtonListener +#endif + /** A base class for buttons. @@ -35788,7 +35833,7 @@ private: class JUCE_API Button : public Component, public SettableTooltipClient, public ApplicationCommandManagerListener, - public Value::Listener, + public ValueListener, private KeyListener { protected: @@ -35911,7 +35956,7 @@ public: @see Button::addButtonListener, Button::removeButtonListener */ - class JUCE_API Listener + class Listener { public: /** Destructor. */ @@ -36230,6 +36275,10 @@ private: /** This typedef is just for compatibility with old code - newer code should use Button::Listener instead. */ typedef Button::Listener ButtonListener; +#if JUCE_VC6 + #undef Listener +#endif + #endif // __JUCE_BUTTON_JUCEHEADER__ /*** End of inlined file: juce_Button.h ***/ @@ -37833,15 +37882,19 @@ typedef TextEditor::Listener TextEditorListener; #endif // __JUCE_TEXTEDITOR_JUCEHEADER__ /*** End of inlined file: juce_TextEditor.h ***/ +#if JUCE_VC6 + #define Listener ButtonListener +#endif + /** A component that displays a text string, and can optionally become a text editor when clicked. */ class JUCE_API Label : public Component, public SettableTooltipClient, - protected TextEditor::Listener, + protected TextEditorListener, private ComponentListener, - private Value::Listener + private ValueListener { public: @@ -38130,9 +38183,17 @@ private: /** This typedef is just for compatibility with old code - newer code should use the Label::Listener class directly. */ typedef Label::Listener LabelListener; +#if JUCE_VC6 + #undef Listener +#endif + #endif // __JUCE_LABEL_JUCEHEADER__ /*** End of inlined file: juce_Label.h ***/ +#if JUCE_VC6 + #define Listener SliderListener +#endif + /** A component that lets the user choose from a drop-down list of choices. @@ -38150,7 +38211,7 @@ typedef Label::Listener LabelListener; class JUCE_API ComboBox : public Component, public SettableTooltipClient, public LabelListener, // (can't use Label::Listener due to idiotic VC2005 bug) - public Value::Listener, + public ValueListener, private AsyncUpdater { public: @@ -38491,6 +38552,10 @@ private: /** This typedef is just for compatibility with old code - newer code should use the ComboBox::Listener class directly. */ typedef ComboBox::Listener ComboBoxListener; +#if JUCE_VC6 + #undef Listener +#endif + #endif // __JUCE_COMBOBOX_JUCEHEADER__ /*** End of inlined file: juce_ComboBox.h ***/ @@ -47168,6 +47233,10 @@ private: #ifndef __JUCE_SLIDER_JUCEHEADER__ #define __JUCE_SLIDER_JUCEHEADER__ +#if JUCE_VC6 + #define Listener LabelListener +#endif + /** A slider control for changing a value. @@ -47193,7 +47262,7 @@ class JUCE_API Slider : public Component, public AsyncUpdater, public ButtonListener, // (can't use Button::Listener due to idiotic VC2005 bug) public LabelListener, - public Value::Listener + public ValueListener { public: @@ -47952,6 +48021,10 @@ private: /** This typedef is just for compatibility with old code - newer code should use the Slider::Listener class directly. */ typedef Slider::Listener SliderListener; +#if JUCE_VC6 + #undef Listener +#endif + #endif // __JUCE_SLIDER_JUCEHEADER__ /*** End of inlined file: juce_Slider.h ***/ @@ -60576,7 +60649,7 @@ public: const Expression getSymbolValue (const String& symbol, const String& member) const; /** Internally-used class for wrapping a DrawableComposite's state into a ValueTree. */ - class ValueTreeWrapper : public ValueTreeWrapperBase + class ValueTreeWrapper : public Drawable::ValueTreeWrapperBase { public: ValueTreeWrapper (const ValueTree& state); @@ -60709,7 +60782,7 @@ public: const Identifier getValueTreeType() const { return valueTreeType; } /** Internally-used class for wrapping a DrawableImage's state into a ValueTree. */ - class ValueTreeWrapper : public ValueTreeWrapperBase + class ValueTreeWrapper : public Drawable::ValueTreeWrapperBase { public: ValueTreeWrapper (const ValueTree& state); @@ -60817,7 +60890,7 @@ public: const PathStrokeType& getStrokeType() const throw() { return strokeType; } /** @internal */ - class FillAndStrokeState : public ValueTreeWrapperBase + class FillAndStrokeState : public Drawable::ValueTreeWrapperBase { public: FillAndStrokeState (const ValueTree& state); @@ -60944,7 +61017,7 @@ public: const Identifier getValueTreeType() const { return valueTreeType; } /** Internally-used class for wrapping a DrawablePath's state into a ValueTree. */ - class ValueTreeWrapper : public FillAndStrokeState + class ValueTreeWrapper : public DrawableShape::FillAndStrokeState { public: ValueTreeWrapper (const ValueTree& state); @@ -61058,7 +61131,7 @@ public: const Identifier getValueTreeType() const { return valueTreeType; } /** Internally-used class for wrapping a DrawableRectangle's state into a ValueTree. */ - class ValueTreeWrapper : public FillAndStrokeState + class ValueTreeWrapper : public DrawableShape::FillAndStrokeState { public: ValueTreeWrapper (const ValueTree& state); @@ -61174,7 +61247,7 @@ public: const Identifier getValueTreeType() const { return valueTreeType; } /** Internally-used class for wrapping a DrawableText's state into a ValueTree. */ - class ValueTreeWrapper : public ValueTreeWrapperBase + class ValueTreeWrapper : public Drawable::ValueTreeWrapperBase { public: ValueTreeWrapper (const ValueTree& state); @@ -61948,6 +62021,7 @@ public: private: class Pimpl; + friend class Pimpl; ImageCache(); ImageCache (const ImageCache&); diff --git a/src/audio/audio_file_formats/juce_AudioCDReader.h b/src/audio/audio_file_formats/juce_AudioCDReader.h index 76e2e78464..6a2a846279 100644 --- a/src/audio/audio_file_formats/juce_AudioCDReader.h +++ b/src/audio/audio_file_formats/juce_AudioCDReader.h @@ -153,8 +153,11 @@ public: void ejectDisk(); //============================================================================== - static const int framesPerSecond = 75; - static const int samplesPerFrame = 44100 / framesPerSecond; + enum + { + framesPerSecond = 75, + samplesPerFrame = 44100 / framesPerSecond + }; //============================================================================== juce_UseDebuggingNewOperator diff --git a/src/audio/audio_file_formats/juce_AudioFormatWriter.h b/src/audio/audio_file_formats/juce_AudioFormatWriter.h index 64494b68aa..a89b20940a 100644 --- a/src/audio/audio_file_formats/juce_AudioFormatWriter.h +++ b/src/audio/audio_file_formats/juce_AudioFormatWriter.h @@ -184,8 +184,10 @@ public: */ bool write (const float** data, int numSamples); + /** @internal */ + class Buffer; // (only public for VC6 compatibility) + private: - class Buffer; friend class ScopedPointer; ScopedPointer buffer; }; @@ -237,6 +239,7 @@ protected: private: String formatName; + friend class ThreadedWriter; AudioFormatWriter (const AudioFormatWriter&); AudioFormatWriter& operator= (const AudioFormatWriter&); diff --git a/src/audio/audio_sources/juce_ResamplingAudioSource.cpp b/src/audio/audio_sources/juce_ResamplingAudioSource.cpp index cea0639495..b92e835cab 100644 --- a/src/audio/audio_sources/juce_ResamplingAudioSource.cpp +++ b/src/audio/audio_sources/juce_ResamplingAudioSource.cpp @@ -205,7 +205,7 @@ void ResamplingAudioSource::createLowPass (const double frequencyRatio) const double proportionalRate = (frequencyRatio > 1.0) ? 0.5 / frequencyRatio : 0.5 * frequencyRatio; - const double n = 1.0 / tan (double_Pi * jmax (0.001, proportionalRate)); + const double n = 1.0 / std::tan (double_Pi * jmax (0.001, proportionalRate)); const double nSquared = n * n; const double c1 = 1.0 / (1.0 + std::sqrt (2.0) * n + nSquared); diff --git a/src/audio/dsp/juce_AudioDataConverters.h b/src/audio/dsp/juce_AudioDataConverters.h index 4bc21dfb7a..656f823cbc 100644 --- a/src/audio/dsp/juce_AudioDataConverters.h +++ b/src/audio/dsp/juce_AudioDataConverters.h @@ -66,6 +66,243 @@ public: class NonConst; /**< Used as a template parameter for AudioData::Pointer. Indicates that the pointer can be used for non-const data. */ class Const; /**< Used as a template parameter for AudioData::Pointer. Indicates that the samples can only be used for const data.. */ + #ifndef DOXYGEN + //============================================================================== + class BigEndian + { + public: + template static inline float getAsFloat (SampleFormatType& s) throw() { return s.getAsFloatBE(); } + template static inline void setAsFloat (SampleFormatType& s, float newValue) throw() { s.setAsFloatBE (newValue); } + template static inline int32 getAsInt32 (SampleFormatType& s) throw() { return s.getAsInt32BE(); } + template static inline void setAsInt32 (SampleFormatType& s, int32 newValue) throw() { s.setAsInt32BE (newValue); } + template static inline void copyFrom (DestType& dest, SourceType& source) throw() { dest.copyFromBE (source); } + enum { isBigEndian = 1 }; + }; + + class LittleEndian + { + public: + template static inline float getAsFloat (SampleFormatType& s) throw() { return s.getAsFloatLE(); } + template static inline void setAsFloat (SampleFormatType& s, float newValue) throw() { s.setAsFloatLE (newValue); } + template static inline int32 getAsInt32 (SampleFormatType& s) throw() { return s.getAsInt32LE(); } + template static inline void setAsInt32 (SampleFormatType& s, int32 newValue) throw() { s.setAsInt32LE (newValue); } + template static inline void copyFrom (DestType& dest, SourceType& source) throw() { dest.copyFromLE (source); } + enum { isBigEndian = 0 }; + }; + + #if JUCE_BIG_ENDIAN + class NativeEndian : public BigEndian {}; + #else + class NativeEndian : public LittleEndian {}; + #endif + + //============================================================================== + class Int8 + { + public: + inline Int8 (void* data_) throw() : data (static_cast (data_)) {} + + inline void advance() throw() { ++data; } + inline void skip (int numSamples) throw() { data += numSamples; } + inline float getAsFloatLE() const throw() { return (float) (*data * (1.0 / (1.0 + maxValue))); } + inline float getAsFloatBE() const throw() { return getAsFloatLE(); } + inline void setAsFloatLE (float newValue) throw() { *data = (int8) jlimit ((int) -maxValue, (int) maxValue, roundToInt (newValue * (1.0 + maxValue))); } + inline void setAsFloatBE (float newValue) throw() { setAsFloatLE (newValue); } + inline int32 getAsInt32LE() const throw() { return (int) (*data << 24); } + inline int32 getAsInt32BE() const throw() { return getAsInt32LE(); } + inline void setAsInt32LE (int newValue) throw() { *data = (int8) (newValue >> 24); } + inline void setAsInt32BE (int newValue) throw() { setAsInt32LE (newValue); } + inline void clear() throw() { *data = 0; } + inline void clearMultiple (int num) throw() { zeromem (data, num * bytesPerSample) ;} + template inline void copyFromLE (SourceType& source) throw() { setAsInt32LE (source.getAsInt32()); } + template inline void copyFromBE (SourceType& source) throw() { setAsInt32BE (source.getAsInt32()); } + inline void copyFromSameType (Int8& source) throw() { *data = *source.data; } + + int8* data; + enum { bytesPerSample = 1, maxValue = 0x7f, resolution = (1 << 24), isFloat = 0 }; + }; + + class UInt8 + { + public: + inline UInt8 (void* data_) throw() : data (static_cast (data_)) {} + + inline void advance() throw() { ++data; } + inline void skip (int numSamples) throw() { data += numSamples; } + inline float getAsFloatLE() const throw() { return (float) ((*data - 128) * (1.0 / (1.0 + maxValue))); } + inline float getAsFloatBE() const throw() { return getAsFloatLE(); } + inline void setAsFloatLE (float newValue) throw() { *data = (uint8) jlimit (0, 255, 128 + roundToInt (newValue * (1.0 + maxValue))); } + inline void setAsFloatBE (float newValue) throw() { setAsFloatLE (newValue); } + inline int32 getAsInt32LE() const throw() { return (int) ((*data - 128) << 24); } + inline int32 getAsInt32BE() const throw() { return getAsInt32LE(); } + inline void setAsInt32LE (int newValue) throw() { *data = (uint8) (128 + (newValue >> 24)); } + inline void setAsInt32BE (int newValue) throw() { setAsInt32LE (newValue); } + inline void clear() throw() { *data = 128; } + inline void clearMultiple (int num) throw() { memset (data, 128, num) ;} + template inline void copyFromLE (SourceType& source) throw() { setAsInt32LE (source.getAsInt32()); } + template inline void copyFromBE (SourceType& source) throw() { setAsInt32BE (source.getAsInt32()); } + inline void copyFromSameType (UInt8& source) throw() { *data = *source.data; } + + uint8* data; + enum { bytesPerSample = 1, maxValue = 0x7f, resolution = (1 << 24), isFloat = 0 }; + }; + + class Int16 + { + public: + inline Int16 (void* data_) throw() : data (static_cast (data_)) {} + + inline void advance() throw() { ++data; } + inline void skip (int numSamples) throw() { data += numSamples; } + inline float getAsFloatLE() const throw() { return (float) ((1.0 / (1.0 + maxValue)) * (int16) ByteOrder::swapIfBigEndian (*data)); } + inline float getAsFloatBE() const throw() { return (float) ((1.0 / (1.0 + maxValue)) * (int16) ByteOrder::swapIfLittleEndian (*data)); } + inline void setAsFloatLE (float newValue) throw() { *data = ByteOrder::swapIfBigEndian ((uint16) jlimit ((int16) -maxValue, (int16) maxValue, (int16) roundToInt (newValue * (1.0 + maxValue)))); } + inline void setAsFloatBE (float newValue) throw() { *data = ByteOrder::swapIfLittleEndian ((uint16) jlimit ((int16) -maxValue, (int16) maxValue, (int16) roundToInt (newValue * (1.0 + maxValue)))); } + inline int32 getAsInt32LE() const throw() { return (int32) (ByteOrder::swapIfBigEndian ((uint16) *data) << 16); } + inline int32 getAsInt32BE() const throw() { return (int32) (ByteOrder::swapIfLittleEndian ((uint16) *data) << 16); } + inline void setAsInt32LE (int32 newValue) throw() { *data = ByteOrder::swapIfBigEndian ((uint16) (newValue >> 16)); } + inline void setAsInt32BE (int32 newValue) throw() { *data = ByteOrder::swapIfLittleEndian ((uint16) (newValue >> 16)); } + inline void clear() throw() { *data = 0; } + inline void clearMultiple (int num) throw() { zeromem (data, num * bytesPerSample) ;} + template inline void copyFromLE (SourceType& source) throw() { setAsInt32LE (source.getAsInt32()); } + template inline void copyFromBE (SourceType& source) throw() { setAsInt32BE (source.getAsInt32()); } + inline void copyFromSameType (Int16& source) throw() { *data = *source.data; } + + uint16* data; + enum { bytesPerSample = 2, maxValue = 0x7fff, resolution = (1 << 16), isFloat = 0 }; + }; + + class Int24 + { + public: + inline Int24 (void* data_) throw() : data (static_cast (data_)) {} + + inline void advance() throw() { data += 3; } + inline void skip (int numSamples) throw() { data += 3 * numSamples; } + inline float getAsFloatLE() const throw() { return (float) (ByteOrder::littleEndian24Bit (data) * (1.0 / (1.0 + maxValue))); } + inline float getAsFloatBE() const throw() { return (float) (ByteOrder::bigEndian24Bit (data) * (1.0 / (1.0 + maxValue))); } + inline void setAsFloatLE (float newValue) throw() { ByteOrder::littleEndian24BitToChars (jlimit ((int) -maxValue, (int) maxValue, roundToInt (newValue * (1.0 + maxValue))), data); } + inline void setAsFloatBE (float newValue) throw() { ByteOrder::bigEndian24BitToChars (jlimit ((int) -maxValue, (int) maxValue, roundToInt (newValue * (1.0 + maxValue))), data); } + inline int32 getAsInt32LE() const throw() { return (int32) ByteOrder::littleEndian24Bit (data) << 8; } + inline int32 getAsInt32BE() const throw() { return (int32) ByteOrder::bigEndian24Bit (data) << 8; } + inline void setAsInt32LE (int32 newValue) throw() { ByteOrder::littleEndian24BitToChars (newValue >> 8, data); } + inline void setAsInt32BE (int32 newValue) throw() { ByteOrder::bigEndian24BitToChars (newValue >> 8, data); } + inline void clear() throw() { data[0] = 0; data[1] = 0; data[2] = 0; } + inline void clearMultiple (int num) throw() { zeromem (data, num * bytesPerSample) ;} + template inline void copyFromLE (SourceType& source) throw() { setAsInt32LE (source.getAsInt32()); } + template inline void copyFromBE (SourceType& source) throw() { setAsInt32BE (source.getAsInt32()); } + inline void copyFromSameType (Int24& source) throw() { data[0] = source.data[0]; data[1] = source.data[1]; data[2] = source.data[2]; } + + char* data; + enum { bytesPerSample = 3, maxValue = 0x7fffff, resolution = (1 << 8), isFloat = 0 }; + }; + + class Int32 + { + public: + inline Int32 (void* data_) throw() : data (static_cast (data_)) {} + + inline void advance() throw() { ++data; } + inline void skip (int numSamples) throw() { data += numSamples; } + inline float getAsFloatLE() const throw() { return (float) ((1.0 / (1.0 + maxValue)) * (int32) ByteOrder::swapIfBigEndian (*data)); } + inline float getAsFloatBE() const throw() { return (float) ((1.0 / (1.0 + maxValue)) * (int32) ByteOrder::swapIfLittleEndian (*data)); } + inline void setAsFloatLE (float newValue) throw() { *data = ByteOrder::swapIfBigEndian ((uint32) jlimit ((int) -maxValue, (int) maxValue, roundToInt (newValue * (1.0 + maxValue)))); } + inline void setAsFloatBE (float newValue) throw() { *data = ByteOrder::swapIfLittleEndian ((uint32) jlimit ((int) -maxValue, (int) maxValue, roundToInt (newValue * (1.0 + maxValue)))); } + inline int32 getAsInt32LE() const throw() { return (int32) ByteOrder::swapIfBigEndian (*data); } + inline int32 getAsInt32BE() const throw() { return (int32) ByteOrder::swapIfLittleEndian (*data); } + inline void setAsInt32LE (int32 newValue) throw() { *data = ByteOrder::swapIfBigEndian ((uint32) newValue); } + inline void setAsInt32BE (int32 newValue) throw() { *data = ByteOrder::swapIfLittleEndian ((uint32) newValue); } + inline void clear() throw() { *data = 0; } + inline void clearMultiple (int num) throw() { zeromem (data, num * bytesPerSample) ;} + template inline void copyFromLE (SourceType& source) throw() { setAsInt32LE (source.getAsInt32()); } + template inline void copyFromBE (SourceType& source) throw() { setAsInt32BE (source.getAsInt32()); } + inline void copyFromSameType (Int32& source) throw() { *data = *source.data; } + + uint32* data; + enum { bytesPerSample = 4, maxValue = 0x7fffffff, resolution = 1, isFloat = 0 }; + }; + + class Float32 + { + public: + inline Float32 (void* data_) throw() : data (static_cast (data_)) {} + + inline void advance() throw() { ++data; } + inline void skip (int numSamples) throw() { data += numSamples; } + #if JUCE_BIG_ENDIAN + inline float getAsFloatBE() const throw() { return *data; } + inline void setAsFloatBE (float newValue) throw() { *data = newValue; } + inline float getAsFloatLE() const throw() { union { uint32 asInt; float asFloat; } n; n.asInt = ByteOrder::swap (*(uint32*) data); return n.asFloat; } + inline void setAsFloatLE (float newValue) throw() { union { uint32 asInt; float asFloat; } n; n.asFloat = newValue; *(uint32*) data = ByteOrder::swap (n.asInt); } + #else + inline float getAsFloatLE() const throw() { return *data; } + inline void setAsFloatLE (float newValue) throw() { *data = newValue; } + inline float getAsFloatBE() const throw() { union { uint32 asInt; float asFloat; } n; n.asInt = ByteOrder::swap (*(uint32*) data); return n.asFloat; } + inline void setAsFloatBE (float newValue) throw() { union { uint32 asInt; float asFloat; } n; n.asFloat = newValue; *(uint32*) data = ByteOrder::swap (n.asInt); } + #endif + inline int32 getAsInt32LE() const throw() { return (int32) roundToInt (jlimit (-1.0f, 1.0f, getAsFloatLE()) * (1.0 + maxValue)); } + inline int32 getAsInt32BE() const throw() { return (int32) roundToInt (jlimit (-1.0f, 1.0f, getAsFloatBE()) * (1.0 + maxValue)); } + inline void setAsInt32LE (int32 newValue) throw() { setAsFloatLE ((float) (newValue * (1.0 / (1.0 + maxValue)))); } + inline void setAsInt32BE (int32 newValue) throw() { setAsFloatBE ((float) (newValue * (1.0 / (1.0 + maxValue)))); } + inline void clear() throw() { *data = 0; } + inline void clearMultiple (int num) throw() { zeromem (data, num * bytesPerSample) ;} + template inline void copyFromLE (SourceType& source) throw() { setAsFloatLE (source.getAsFloat()); } + template inline void copyFromBE (SourceType& source) throw() { setAsFloatBE (source.getAsFloat()); } + inline void copyFromSameType (Float32& source) throw() { *data = *source.data; } + + float* data; + enum { bytesPerSample = 4, maxValue = 0x7fffffff, resolution = (1 << 8), isFloat = 1 }; + }; + + //============================================================================== + class NonInterleaved + { + public: + inline NonInterleaved() throw() {} + inline NonInterleaved (const NonInterleaved&) throw() {} + inline NonInterleaved (const int) throw() {} + inline void copyFrom (const NonInterleaved&) throw() {} + template inline void advanceData (SampleFormatType& s) throw() { s.advance(); } + template inline void advanceDataBy (SampleFormatType& s, int numSamples) throw() { s.skip (numSamples); } + template inline void clear (SampleFormatType& s, int numSamples) throw() { s.clearMultiple (numSamples); } + template inline static int getNumBytesBetweenSamples (const SampleFormatType&) throw() { return SampleFormatType::bytesPerSample; } + + enum { isInterleavedType = 0, numInterleavedChannels = 1 }; + }; + + class Interleaved + { + public: + inline Interleaved() throw() : numInterleavedChannels (1) {} + inline Interleaved (const Interleaved& other) throw() : numInterleavedChannels (other.numInterleavedChannels) {} + inline Interleaved (const int numInterleavedChannels_) throw() : numInterleavedChannels (numInterleavedChannels_) {} + inline void copyFrom (const Interleaved& other) throw() { numInterleavedChannels = other.numInterleavedChannels; } + template inline void advanceData (SampleFormatType& s) throw() { s.skip (numInterleavedChannels); } + template inline void advanceDataBy (SampleFormatType& s, int numSamples) throw() { s.skip (numInterleavedChannels * numSamples); } + template inline void clear (SampleFormatType& s, int numSamples) throw() { while (--numSamples >= 0) { s.clear(); s.skip (numInterleavedChannels); } } + template inline int getNumBytesBetweenSamples (const SampleFormatType&) const throw() { return numInterleavedChannels * SampleFormatType::bytesPerSample; } + int numInterleavedChannels; + enum { isInterleavedType = 1 }; + }; + + //============================================================================== + class NonConst + { + public: + typedef void VoidType; + static inline void* toVoidPtr (VoidType* v) throw() { return v; } + enum { isConst = 0 }; + }; + + class Const + { + public: + typedef const void VoidType; + static inline void* toVoidPtr (VoidType* v) throw() { return const_cast (v); } + enum { isConst = 1 }; + }; + #endif + //============================================================================== /** A pointer to a block of audio data with a particular encoding. @@ -95,7 +332,7 @@ public: typename Endianness, typename InterleavingType, typename Constness> - class Pointer : private InterleavingType + class Pointer { public: //============================================================================== @@ -115,22 +352,22 @@ public: For non-interleaved data, use the other constructor. */ Pointer (typename Constness::VoidType* sourceData, int numInterleavedChannels) throw() - : InterleavingType (numInterleavedChannels), - data (Constness::toVoidPtr (sourceData)) + : data (Constness::toVoidPtr (sourceData)), + interleaving (numInterleavedChannels) { } /** Creates a copy of another pointer. */ Pointer (const Pointer& other) throw() - : InterleavingType (other), - data (other.data) + : data (other.data), + interleaving (other.interleaving) { } Pointer& operator= (const Pointer& other) throw() { data = other.data; - InterleavingType::copyFrom (other); + interleaving.copyFrom (other.interleaving); return *this; } @@ -175,10 +412,10 @@ public: inline Pointer& operator++() throw() { advance(); return *this; } /** Moves the pointer back to the previous sample. */ - inline Pointer& operator--() throw() { advanceDataBy (data, -1); return *this; } + inline Pointer& operator--() throw() { interleaving.advanceDataBy (data, -1); return *this; } /** Adds a number of samples to the pointer's position. */ - Pointer& operator+= (int samplesToJump) throw() { advanceDataBy (data, samplesToJump); return *this; } + Pointer& operator+= (int samplesToJump) throw() { interleaving.advanceDataBy (data, samplesToJump); return *this; } /** Writes a stream of samples into this pointer from another pointer. This will copy the specified number of samples, converting between formats appropriately. @@ -229,7 +466,7 @@ public: void clearSamples (int numSamples) const throw() { Pointer dest (*this); - dest.clear (dest.data, numSamples); + dest.interleaving.clear (dest.data, numSamples); } /** Returns true if the pointer is using a floating-point format. */ @@ -245,7 +482,7 @@ public: int getNumInterleavedChannels() const throw() { return (int) this->numInterleavedChannels; } /** Returns the number of bytes between the start address of each sample. */ - int getNumBytesBetweenSamples() const throw() { return InterleavingType::getNumBytesBetweenSamples (data); } + int getNumBytesBetweenSamples() const throw() { return interleaving.getNumBytesBetweenSamples (data); } /** Returns the accuracy of this format when represented as a 32-bit integer. This is the smallest number above 0 that can be represented in the sample format, converted to @@ -260,8 +497,10 @@ public: private: //============================================================================== SampleFormat data; + InterleavingType interleaving; // annoyingly, making the interleaving type a superclass to take + // advantage of EBCO causes an internal compiler error in VC6.. - inline void advance() throw() { advanceData (data); } + inline void advance() throw() { interleaving.advanceData (data); } Pointer operator++ (int); // private to force you to use the more efficient pre-increment! Pointer operator-- (int); @@ -337,244 +576,6 @@ public: }; -#ifndef DOXYGEN - -//============================================================================== -class AudioData::BigEndian -{ -public: - template static inline float getAsFloat (SampleFormatType& s) throw() { return s.getAsFloatBE(); } - template static inline void setAsFloat (SampleFormatType& s, float newValue) throw() { s.setAsFloatBE (newValue); } - template static inline int32 getAsInt32 (SampleFormatType& s) throw() { return s.getAsInt32BE(); } - template static inline void setAsInt32 (SampleFormatType& s, int32 newValue) throw() { s.setAsInt32BE (newValue); } - template static inline void copyFrom (DestType& dest, SourceType& source) throw() { dest.copyFromBE (source); } - enum { isBigEndian = 1 }; -}; - -class AudioData::LittleEndian -{ -public: - template static inline float getAsFloat (SampleFormatType& s) throw() { return s.getAsFloatLE(); } - template static inline void setAsFloat (SampleFormatType& s, float newValue) throw() { s.setAsFloatLE (newValue); } - template static inline int32 getAsInt32 (SampleFormatType& s) throw() { return s.getAsInt32LE(); } - template static inline void setAsInt32 (SampleFormatType& s, int32 newValue) throw() { s.setAsInt32LE (newValue); } - template static inline void copyFrom (DestType& dest, SourceType& source) throw() { dest.copyFromLE (source); } - enum { isBigEndian = 0 }; -}; - -#if JUCE_BIG_ENDIAN - class AudioData::NativeEndian : public AudioData::BigEndian {}; -#else - class AudioData::NativeEndian : public AudioData::LittleEndian {}; -#endif - -//============================================================================== -class AudioData::Int8 -{ -public: - inline Int8 (void* data_) throw() : data (static_cast (data_)) {} - - inline void advance() throw() { ++data; } - inline void skip (int numSamples) throw() { data += numSamples; } - inline float getAsFloatLE() const throw() { return (float) (*data * (1.0 / (1.0 + maxValue))); } - inline float getAsFloatBE() const throw() { return getAsFloatLE(); } - inline void setAsFloatLE (float newValue) throw() { *data = (int8) jlimit ((int) -maxValue, (int) maxValue, roundToInt (newValue * (1.0 + maxValue))); } - inline void setAsFloatBE (float newValue) throw() { setAsFloatLE (newValue); } - inline int32 getAsInt32LE() const throw() { return (int) (*data << 24); } - inline int32 getAsInt32BE() const throw() { return getAsInt32LE(); } - inline void setAsInt32LE (int newValue) throw() { *data = (int8) (newValue >> 24); } - inline void setAsInt32BE (int newValue) throw() { setAsInt32LE (newValue); } - inline void clear() throw() { *data = 0; } - inline void clearMultiple (int num) throw() { zeromem (data, num * bytesPerSample) ;} - template inline void copyFromLE (SourceType& source) throw() { setAsInt32LE (source.getAsInt32()); } - template inline void copyFromBE (SourceType& source) throw() { setAsInt32BE (source.getAsInt32()); } - inline void copyFromSameType (Int8& source) throw() { *data = *source.data; } - - int8* data; - enum { bytesPerSample = 1, maxValue = 0x7f, resolution = (1 << 24), isFloat = 0 }; -}; - -class AudioData::UInt8 -{ -public: - inline UInt8 (void* data_) throw() : data (static_cast (data_)) {} - - inline void advance() throw() { ++data; } - inline void skip (int numSamples) throw() { data += numSamples; } - inline float getAsFloatLE() const throw() { return (float) ((*data - 128) * (1.0 / (1.0 + maxValue))); } - inline float getAsFloatBE() const throw() { return getAsFloatLE(); } - inline void setAsFloatLE (float newValue) throw() { *data = (uint8) jlimit (0, 255, 128 + roundToInt (newValue * (1.0 + maxValue))); } - inline void setAsFloatBE (float newValue) throw() { setAsFloatLE (newValue); } - inline int32 getAsInt32LE() const throw() { return (int) ((*data - 128) << 24); } - inline int32 getAsInt32BE() const throw() { return getAsInt32LE(); } - inline void setAsInt32LE (int newValue) throw() { *data = (uint8) (128 + (newValue >> 24)); } - inline void setAsInt32BE (int newValue) throw() { setAsInt32LE (newValue); } - inline void clear() throw() { *data = 128; } - inline void clearMultiple (int num) throw() { memset (data, 128, num) ;} - template inline void copyFromLE (SourceType& source) throw() { setAsInt32LE (source.getAsInt32()); } - template inline void copyFromBE (SourceType& source) throw() { setAsInt32BE (source.getAsInt32()); } - inline void copyFromSameType (UInt8& source) throw() { *data = *source.data; } - - uint8* data; - enum { bytesPerSample = 1, maxValue = 0x7f, resolution = (1 << 24), isFloat = 0 }; -}; - -class AudioData::Int16 -{ -public: - inline Int16 (void* data_) throw() : data (static_cast (data_)) {} - - inline void advance() throw() { ++data; } - inline void skip (int numSamples) throw() { data += numSamples; } - inline float getAsFloatLE() const throw() { return (float) ((1.0 / (1.0 + maxValue)) * (int16) ByteOrder::swapIfBigEndian (*data)); } - inline float getAsFloatBE() const throw() { return (float) ((1.0 / (1.0 + maxValue)) * (int16) ByteOrder::swapIfLittleEndian (*data)); } - inline void setAsFloatLE (float newValue) throw() { *data = ByteOrder::swapIfBigEndian ((uint16) jlimit ((int16) -maxValue, (int16) maxValue, (int16) roundToInt (newValue * (1.0 + maxValue)))); } - inline void setAsFloatBE (float newValue) throw() { *data = ByteOrder::swapIfLittleEndian ((uint16) jlimit ((int16) -maxValue, (int16) maxValue, (int16) roundToInt (newValue * (1.0 + maxValue)))); } - inline int32 getAsInt32LE() const throw() { return (int32) (ByteOrder::swapIfBigEndian ((uint16) *data) << 16); } - inline int32 getAsInt32BE() const throw() { return (int32) (ByteOrder::swapIfLittleEndian ((uint16) *data) << 16); } - inline void setAsInt32LE (int32 newValue) throw() { *data = ByteOrder::swapIfBigEndian ((uint16) (newValue >> 16)); } - inline void setAsInt32BE (int32 newValue) throw() { *data = ByteOrder::swapIfLittleEndian ((uint16) (newValue >> 16)); } - inline void clear() throw() { *data = 0; } - inline void clearMultiple (int num) throw() { zeromem (data, num * bytesPerSample) ;} - template inline void copyFromLE (SourceType& source) throw() { setAsInt32LE (source.getAsInt32()); } - template inline void copyFromBE (SourceType& source) throw() { setAsInt32BE (source.getAsInt32()); } - inline void copyFromSameType (Int16& source) throw() { *data = *source.data; } - - uint16* data; - enum { bytesPerSample = 2, maxValue = 0x7fff, resolution = (1 << 16), isFloat = 0 }; -}; - -class AudioData::Int24 -{ -public: - inline Int24 (void* data_) throw() : data (static_cast (data_)) {} - - inline void advance() throw() { data += 3; } - inline void skip (int numSamples) throw() { data += 3 * numSamples; } - inline float getAsFloatLE() const throw() { return (float) (ByteOrder::littleEndian24Bit (data) * (1.0 / (1.0 + maxValue))); } - inline float getAsFloatBE() const throw() { return (float) (ByteOrder::bigEndian24Bit (data) * (1.0 / (1.0 + maxValue))); } - inline void setAsFloatLE (float newValue) throw() { ByteOrder::littleEndian24BitToChars (jlimit ((int) -maxValue, (int) maxValue, roundToInt (newValue * (1.0 + maxValue))), data); } - inline void setAsFloatBE (float newValue) throw() { ByteOrder::bigEndian24BitToChars (jlimit ((int) -maxValue, (int) maxValue, roundToInt (newValue * (1.0 + maxValue))), data); } - inline int32 getAsInt32LE() const throw() { return (int32) ByteOrder::littleEndian24Bit (data) << 8; } - inline int32 getAsInt32BE() const throw() { return (int32) ByteOrder::bigEndian24Bit (data) << 8; } - inline void setAsInt32LE (int32 newValue) throw() { ByteOrder::littleEndian24BitToChars (newValue >> 8, data); } - inline void setAsInt32BE (int32 newValue) throw() { ByteOrder::bigEndian24BitToChars (newValue >> 8, data); } - inline void clear() throw() { data[0] = 0; data[1] = 0; data[2] = 0; } - inline void clearMultiple (int num) throw() { zeromem (data, num * bytesPerSample) ;} - template inline void copyFromLE (SourceType& source) throw() { setAsInt32LE (source.getAsInt32()); } - template inline void copyFromBE (SourceType& source) throw() { setAsInt32BE (source.getAsInt32()); } - inline void copyFromSameType (Int24& source) throw() { data[0] = source.data[0]; data[1] = source.data[1]; data[2] = source.data[2]; } - - char* data; - enum { bytesPerSample = 3, maxValue = 0x7fffff, resolution = (1 << 8), isFloat = 0 }; -}; - -class AudioData::Int32 -{ -public: - inline Int32 (void* data_) throw() : data (static_cast (data_)) {} - - inline void advance() throw() { ++data; } - inline void skip (int numSamples) throw() { data += numSamples; } - inline float getAsFloatLE() const throw() { return (float) ((1.0 / (1.0 + maxValue)) * (int32) ByteOrder::swapIfBigEndian (*data)); } - inline float getAsFloatBE() const throw() { return (float) ((1.0 / (1.0 + maxValue)) * (int32) ByteOrder::swapIfLittleEndian (*data)); } - inline void setAsFloatLE (float newValue) throw() { *data = ByteOrder::swapIfBigEndian ((uint32) jlimit ((int) -maxValue, (int) maxValue, roundToInt (newValue * (1.0 + maxValue)))); } - inline void setAsFloatBE (float newValue) throw() { *data = ByteOrder::swapIfLittleEndian ((uint32) jlimit ((int) -maxValue, (int) maxValue, roundToInt (newValue * (1.0 + maxValue)))); } - inline int32 getAsInt32LE() const throw() { return (int32) ByteOrder::swapIfBigEndian (*data); } - inline int32 getAsInt32BE() const throw() { return (int32) ByteOrder::swapIfLittleEndian (*data); } - inline void setAsInt32LE (int32 newValue) throw() { *data = ByteOrder::swapIfBigEndian ((uint32) newValue); } - inline void setAsInt32BE (int32 newValue) throw() { *data = ByteOrder::swapIfLittleEndian ((uint32) newValue); } - inline void clear() throw() { *data = 0; } - inline void clearMultiple (int num) throw() { zeromem (data, num * bytesPerSample) ;} - template inline void copyFromLE (SourceType& source) throw() { setAsInt32LE (source.getAsInt32()); } - template inline void copyFromBE (SourceType& source) throw() { setAsInt32BE (source.getAsInt32()); } - inline void copyFromSameType (Int32& source) throw() { *data = *source.data; } - - uint32* data; - enum { bytesPerSample = 4, maxValue = 0x7fffffff, resolution = 1, isFloat = 0 }; -}; - -class AudioData::Float32 -{ -public: - inline Float32 (void* data_) throw() : data (static_cast (data_)) {} - - inline void advance() throw() { ++data; } - inline void skip (int numSamples) throw() { data += numSamples; } - #if JUCE_BIG_ENDIAN - inline float getAsFloatBE() const throw() { return *data; } - inline void setAsFloatBE (float newValue) throw() { *data = newValue; } - inline float getAsFloatLE() const throw() { union { uint32 asInt; float asFloat; } n; n.asInt = ByteOrder::swap (*(uint32*) data); return n.asFloat; } - inline void setAsFloatLE (float newValue) throw() { union { uint32 asInt; float asFloat; } n; n.asFloat = newValue; *(uint32*) data = ByteOrder::swap (n.asInt); } - #else - inline float getAsFloatLE() const throw() { return *data; } - inline void setAsFloatLE (float newValue) throw() { *data = newValue; } - inline float getAsFloatBE() const throw() { union { uint32 asInt; float asFloat; } n; n.asInt = ByteOrder::swap (*(uint32*) data); return n.asFloat; } - inline void setAsFloatBE (float newValue) throw() { union { uint32 asInt; float asFloat; } n; n.asFloat = newValue; *(uint32*) data = ByteOrder::swap (n.asInt); } - #endif - inline int32 getAsInt32LE() const throw() { return (int32) roundToInt (jlimit (-1.0f, 1.0f, getAsFloatLE()) * (1.0 + maxValue)); } - inline int32 getAsInt32BE() const throw() { return (int32) roundToInt (jlimit (-1.0f, 1.0f, getAsFloatBE()) * (1.0 + maxValue)); } - inline void setAsInt32LE (int32 newValue) throw() { setAsFloatLE ((float) (newValue * (1.0 / (1.0 + maxValue)))); } - inline void setAsInt32BE (int32 newValue) throw() { setAsFloatBE ((float) (newValue * (1.0 / (1.0 + maxValue)))); } - inline void clear() throw() { *data = 0; } - inline void clearMultiple (int num) throw() { zeromem (data, num * bytesPerSample) ;} - template inline void copyFromLE (SourceType& source) throw() { setAsFloatLE (source.getAsFloat()); } - template inline void copyFromBE (SourceType& source) throw() { setAsFloatBE (source.getAsFloat()); } - inline void copyFromSameType (Float32& source) throw() { *data = *source.data; } - - float* data; - enum { bytesPerSample = 4, maxValue = 0x7fffffff, resolution = (1 << 8), isFloat = 1 }; -}; - -//============================================================================== -class AudioData::NonInterleaved -{ -public: - inline NonInterleaved() throw() {} - inline NonInterleaved (const NonInterleaved&) throw() {} - inline NonInterleaved (const int) throw() {} - inline void copyFrom (const NonInterleaved&) throw() {} - template inline void advanceData (SampleFormatType& s) throw() { s.advance(); } - template inline void advanceDataBy (SampleFormatType& s, int numSamples) throw() { s.skip (numSamples); } - template inline void clear (SampleFormatType& s, int numSamples) throw() { s.clearMultiple (numSamples); } - template inline static int getNumBytesBetweenSamples (const SampleFormatType&) throw() { return SampleFormatType::bytesPerSample; } - - enum { isInterleavedType = 0, numInterleavedChannels = 1 }; -}; - -class AudioData::Interleaved -{ -public: - inline Interleaved() throw() : numInterleavedChannels (1) {} - inline Interleaved (const Interleaved& other) throw() : numInterleavedChannels (other.numInterleavedChannels) {} - inline Interleaved (const int numInterleavedChannels_) throw() : numInterleavedChannels (numInterleavedChannels_) {} - inline void copyFrom (const Interleaved& other) throw() { numInterleavedChannels = other.numInterleavedChannels; } - template inline void advanceData (SampleFormatType& s) throw() { s.skip (numInterleavedChannels); } - template inline void advanceDataBy (SampleFormatType& s, int numSamples) throw() { s.skip (numInterleavedChannels * numSamples); } - template inline void clear (SampleFormatType& s, int numSamples) throw() { while (--numSamples >= 0) { s.clear(); s.skip (numInterleavedChannels); } } - template inline int getNumBytesBetweenSamples (const SampleFormatType&) const throw() { return numInterleavedChannels * SampleFormatType::bytesPerSample; } - int numInterleavedChannels; - enum { isInterleavedType = 1 }; -}; - -//============================================================================== -class AudioData::NonConst -{ -public: - typedef void VoidType; - static inline void* toVoidPtr (VoidType* v) throw() { return v; } - enum { isConst = 0 }; -}; - -class AudioData::Const -{ -public: - typedef const void VoidType; - static inline void* toVoidPtr (VoidType* v) throw() { return const_cast (v); } - enum { isConst = 1 }; -}; - -#endif //============================================================================== /** diff --git a/src/containers/juce_Array.h b/src/containers/juce_Array.h index d38632a80c..06dc00405e 100644 --- a/src/containers/juce_Array.h +++ b/src/containers/juce_Array.h @@ -60,7 +60,7 @@ template TermPtr; + // This helper function is needed to work around VC6 scoping bugs + static const TermPtr& getTermFor (const Expression& exp) throw() { return exp.term; } + + friend class Expression::Term; // (also only needed as a VC6 workaround) + //============================================================================== class Constant : public Term { @@ -88,7 +93,7 @@ public: try { - return c.getSymbolValue (mainSymbol, member).term->evaluate (c, recursionDepth); + return getTermFor (c.getSymbolValue (mainSymbol, member))->evaluate (c, recursionDepth); } catch (...) {} @@ -118,7 +123,7 @@ public: try { - return c != 0 && c->getSymbolValue (mainSymbol, member).term->referencesSymbol (s, c, recursionDepth); + return c != 0 && getTermFor (c->getSymbolValue (mainSymbol, member))->referencesSymbol (s, c, recursionDepth); } catch (EvaluationError&) { diff --git a/src/containers/juce_ScopedPointer.h b/src/containers/juce_ScopedPointer.h index f439c29a53..9627d2d7eb 100644 --- a/src/containers/juce_ScopedPointer.h +++ b/src/containers/juce_ScopedPointer.h @@ -178,7 +178,7 @@ private: This can be handy for checking whether this is a null pointer. */ template -inline bool operator== (const ScopedPointer& pointer1, const ObjectType* const pointer2) throw() +bool operator== (const ScopedPointer& pointer1, ObjectType* const pointer2) throw() { return static_cast (pointer1) == pointer2; } @@ -187,7 +187,7 @@ inline bool operator== (const ScopedPointer& pointer1, const ObjectT This can be handy for checking whether this is a null pointer. */ template -inline bool operator!= (const ScopedPointer& pointer1, const ObjectType* const pointer2) throw() +bool operator!= (const ScopedPointer& pointer1, ObjectType* const pointer2) throw() { return static_cast (pointer1) != pointer2; } diff --git a/src/containers/juce_Value.cpp b/src/containers/juce_Value.cpp index 99810dd6dc..ce06b34507 100644 --- a/src/containers/juce_Value.cpp +++ b/src/containers/juce_Value.cpp @@ -192,7 +192,7 @@ bool Value::operator!= (const Value& other) const } //============================================================================== -void Value::addListener (Listener* const listener) +void Value::addListener (ValueListener* const listener) { if (listener != 0) { @@ -203,7 +203,7 @@ void Value::addListener (Listener* const listener) } } -void Value::removeListener (Listener* const listener) +void Value::removeListener (ValueListener* const listener) { listeners.remove (listener); @@ -214,7 +214,7 @@ void Value::removeListener (Listener* const listener) void Value::callListeners() { Value v (*this); // (create a copy in case this gets deleted by a callback) - listeners.call (&Value::Listener::valueChanged, v); + listeners.call (&ValueListener::valueChanged, v); } OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const Value& value) diff --git a/src/containers/juce_Value.h b/src/containers/juce_Value.h index 49820c1cfa..c16c59c323 100644 --- a/src/containers/juce_Value.h +++ b/src/containers/juce_Value.h @@ -233,5 +233,7 @@ private: /** Writes a Value to an OutputStream as a UTF8 string. */ OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const Value& value); +/** This typedef is just for compatibility with old code - newer code should use the Value::Listener class directly. */ +typedef Value::Listener ValueListener; #endif // __JUCE_VALUE_JUCEHEADER__ diff --git a/src/core/juce_MathsFunctions.h b/src/core/juce_MathsFunctions.h index 198cd40387..394d46d467 100644 --- a/src/core/juce_MathsFunctions.h +++ b/src/core/juce_MathsFunctions.h @@ -79,7 +79,7 @@ typedef unsigned int uint32; typedef int64 pointer_sized_int; /** An unsigned integer type that's guaranteed to be large enough to hold a pointer without truncating it. */ typedef uint64 pointer_sized_uint; -#elif _MSC_VER >= 1300 +#elif JUCE_MSVC && ! JUCE_VC6 /** A signed integer type that's guaranteed to be large enough to hold a pointer without truncating it. */ typedef _W64 int pointer_sized_int; /** An unsigned integer type that's guaranteed to be large enough to hold a pointer without truncating it. */ @@ -163,22 +163,26 @@ inline void swapVariables (Type& variable1, Type& variable2) variable2 = tempVal; } -/** Handy function for getting the number of elements in a simple const C array. +#if JUCE_VC6 + #define numElementsInArray(X) (sizeof((X)) / sizeof(0[X])) +#else + /** Handy function for getting the number of elements in a simple const C array. - E.g. - @code - static int myArray[] = { 1, 2, 3 }; + E.g. + @code + static int myArray[] = { 1, 2, 3 }; - int numElements = numElementsInArray (myArray) // returns 3 - @endcode -*/ -template -inline int numElementsInArray (Type (&array)[N]) -{ - (void) array; // (required to avoid a spurious warning in MS compilers) - sizeof (0[array]); // This line should cause an error if you pass an object with a user-defined subscript operator - return N; -} + int numElements = numElementsInArray (myArray) // returns 3 + @endcode + */ + template + inline int numElementsInArray (Type (&array)[N]) + { + (void) array; // (required to avoid a spurious warning in MS compilers) + sizeof (0[array]); // This line should cause an error if you pass an object with a user-defined subscript operator + return N; + } +#endif //============================================================================== // Some useful maths functions that aren't always present with all compilers and build settings. @@ -327,9 +331,9 @@ inline int roundFloatToInt (const float value) throw() */ namespace TypeHelpers { -#if defined (_MSC_VER) && _MSC_VER <= 1400 + #if JUCE_VC8_OR_EARLIER #define PARAMETER_TYPE(a) a -#else + #else /** The ParameterType struct is used to find the best type to use when passing some kind of object as a parameter. @@ -344,7 +348,7 @@ namespace TypeHelpers */ template struct ParameterType { typedef const Type& type; }; -#if ! DOXYGEN + #if ! DOXYGEN template struct ParameterType { typedef Type& type; }; template struct ParameterType { typedef Type* type; }; template <> struct ParameterType { typedef char type; }; @@ -360,13 +364,13 @@ namespace TypeHelpers template <> struct ParameterType { typedef bool type; }; template <> struct ParameterType { typedef float type; }; template <> struct ParameterType { typedef double type; }; -#endif + #endif /** A helpful macro to simplify the use of the ParameterType template. @see ParameterType */ #define PARAMETER_TYPE(a) typename TypeHelpers::ParameterType::type -#endif + #endif } diff --git a/src/core/juce_StandardHeader.h b/src/core/juce_StandardHeader.h index b021beb688..97869a0d17 100644 --- a/src/core/juce_StandardHeader.h +++ b/src/core/juce_StandardHeader.h @@ -33,7 +33,7 @@ */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 52 -#define JUCE_BUILDNUMBER 91 +#define JUCE_BUILDNUMBER 92 /** Current Juce version number. @@ -65,8 +65,20 @@ // Now we'll include any OS headers we need.. (at this point we are outside the Juce namespace). #if JUCE_MSVC - #if (defined(_MSC_VER) && (_MSC_VER <= 1200)) + #if JUCE_VC6 #pragma warning (disable: 4284 4786) // (spurious VC6 warnings) + + namespace std // VC6 doesn't have sqrt/sin/cos/tan/abs in std, so declare them here: + { + template Type abs (Type a) { if (a < 0) return -a; return a; } + template Type tan (Type a) { return static_cast (::tan (static_cast (a))); } + template Type sin (Type a) { return static_cast (::sin (static_cast (a))); } + template Type cos (Type a) { return static_cast (::cos (static_cast (a))); } + template Type sqrt (Type a) { return static_cast (::sqrt (static_cast (a))); } + template Type floor (Type a) { return static_cast (::floor (static_cast (a))); } + template Type ceil (Type a) { return static_cast (::ceil (static_cast (a))); } + template Type atan2 (Type a, Type b) { return static_cast (::atan2 (static_cast (a), static_cast (b))); } + } #endif #pragma warning (push) diff --git a/src/core/juce_TargetPlatform.h b/src/core/juce_TargetPlatform.h index 2892f06313..1287da1ea7 100644 --- a/src/core/juce_TargetPlatform.h +++ b/src/core/juce_TargetPlatform.h @@ -160,7 +160,19 @@ #elif defined (_MSC_VER) #define JUCE_MSVC 1 - #if _MSC_VER >= 1400 + #if _MSC_VER < 1500 + #define JUCE_VC8_OR_EARLIER 1 + + #if _MSC_VER < 1400 + #define JUCE_VC7_OR_EARLIER 1 + + #if _MSC_VER < 1300 + #define JUCE_VC6 1 + #endif + #endif + #endif + + #if ! JUCE_VC7_OR_EARLIER #define JUCE_USE_INTRINSICS 1 #endif #else diff --git a/src/events/juce_ListenerList.h b/src/events/juce_ListenerList.h index 89128842ad..659008007d 100644 --- a/src/events/juce_ListenerList.h +++ b/src/events/juce_ListenerList.h @@ -72,7 +72,7 @@ template & mappings_) diff --git a/src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp b/src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp index c498766eae..caf8e934be 100644 --- a/src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp +++ b/src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp @@ -414,7 +414,7 @@ private: }; //============================================================================== -namespace +namespace RenderingHelpers { forcedinline int safeModulo (int n, const int divisor) throw() { @@ -436,8 +436,8 @@ public: : destData (destData_), srcData (srcData_), extraAlpha (extraAlpha_ + 1), - xOffset (repeatPattern ? safeModulo (x, srcData_.width) - srcData_.width : x), - yOffset (repeatPattern ? safeModulo (y, srcData_.height) - srcData_.height : y) + xOffset (repeatPattern ? RenderingHelpers::safeModulo (x, srcData_.width) - srcData_.width : x), + yOffset (repeatPattern ? RenderingHelpers::safeModulo (y, srcData_.height) - srcData_.height : y) { } @@ -680,8 +680,8 @@ private: if (repeatPattern) { - loResX = safeModulo (loResX, srcData.width); - loResY = safeModulo (loResY, srcData.height); + loResX = RenderingHelpers::safeModulo (loResX, srcData.width); + loResY = RenderingHelpers::safeModulo (loResY, srcData.height); } if (betterQuality) diff --git a/src/gui/graphics/drawables/juce_DrawableComposite.cpp b/src/gui/graphics/drawables/juce_DrawableComposite.cpp index 94a8763dd9..24f6e0fa3e 100644 --- a/src/gui/graphics/drawables/juce_DrawableComposite.cpp +++ b/src/gui/graphics/drawables/juce_DrawableComposite.cpp @@ -118,10 +118,10 @@ bool DrawableComposite::Marker::operator!= (const DrawableComposite::Marker& oth } //============================================================================== -const char* const DrawableComposite::contentLeftMarkerName ("left"); -const char* const DrawableComposite::contentRightMarkerName ("right"); -const char* const DrawableComposite::contentTopMarkerName ("top"); -const char* const DrawableComposite::contentBottomMarkerName ("bottom"); +const char* const DrawableComposite::contentLeftMarkerName = "left"; +const char* const DrawableComposite::contentRightMarkerName = "right"; +const char* const DrawableComposite::contentTopMarkerName = "top"; +const char* const DrawableComposite::contentBottomMarkerName = "bottom"; const RelativeRectangle DrawableComposite::getContentArea() const { @@ -560,7 +560,7 @@ void DrawableComposite::ValueTreeWrapper::removeMarker (bool xAxis, const ValueT && state [nameProperty].toString() != contentRightMarkerName && state [nameProperty].toString() != contentTopMarkerName && state [nameProperty].toString() != contentBottomMarkerName) - return getMarkerList (xAxis).removeChild (state, undoManager); + getMarkerList (xAxis).removeChild (state, undoManager); } //============================================================================== diff --git a/src/gui/graphics/drawables/juce_DrawableComposite.h b/src/gui/graphics/drawables/juce_DrawableComposite.h index b76db87f0e..799cb32c68 100644 --- a/src/gui/graphics/drawables/juce_DrawableComposite.h +++ b/src/gui/graphics/drawables/juce_DrawableComposite.h @@ -205,7 +205,7 @@ public: //============================================================================== /** Internally-used class for wrapping a DrawableComposite's state into a ValueTree. */ - class ValueTreeWrapper : public ValueTreeWrapperBase + class ValueTreeWrapper : public Drawable::ValueTreeWrapperBase { public: ValueTreeWrapper (const ValueTree& state); diff --git a/src/gui/graphics/drawables/juce_DrawableImage.h b/src/gui/graphics/drawables/juce_DrawableImage.h index 7695c737c6..5079ef1189 100644 --- a/src/gui/graphics/drawables/juce_DrawableImage.h +++ b/src/gui/graphics/drawables/juce_DrawableImage.h @@ -104,7 +104,7 @@ public: //============================================================================== /** Internally-used class for wrapping a DrawableImage's state into a ValueTree. */ - class ValueTreeWrapper : public ValueTreeWrapperBase + class ValueTreeWrapper : public Drawable::ValueTreeWrapperBase { public: ValueTreeWrapper (const ValueTree& state); diff --git a/src/gui/graphics/drawables/juce_DrawablePath.cpp b/src/gui/graphics/drawables/juce_DrawablePath.cpp index 5340bd2bd0..8dd147a3b3 100644 --- a/src/gui/graphics/drawables/juce_DrawablePath.cpp +++ b/src/gui/graphics/drawables/juce_DrawablePath.cpp @@ -168,7 +168,7 @@ Value DrawablePath::ValueTreeWrapper::Element::getControlPointValue (int index, void DrawablePath::ValueTreeWrapper::Element::setControlPoint (const int index, const RelativePoint& point, UndoManager* undoManager) { jassert (index >= 0 && index < getNumControlPoints()); - return state.setProperty (index == 0 ? point1 : (index == 1 ? point2 : point3), point.toString(), undoManager); + state.setProperty (index == 0 ? point1 : (index == 1 ? point2 : point3), point.toString(), undoManager); } const RelativePoint DrawablePath::ValueTreeWrapper::Element::getStartPoint() const diff --git a/src/gui/graphics/drawables/juce_DrawablePath.h b/src/gui/graphics/drawables/juce_DrawablePath.h index c7e5b0d47e..a471162851 100644 --- a/src/gui/graphics/drawables/juce_DrawablePath.h +++ b/src/gui/graphics/drawables/juce_DrawablePath.h @@ -74,7 +74,7 @@ public: //============================================================================== /** Internally-used class for wrapping a DrawablePath's state into a ValueTree. */ - class ValueTreeWrapper : public FillAndStrokeState + class ValueTreeWrapper : public DrawableShape::FillAndStrokeState { public: ValueTreeWrapper (const ValueTree& state); diff --git a/src/gui/graphics/drawables/juce_DrawableRectangle.h b/src/gui/graphics/drawables/juce_DrawableRectangle.h index c8e067920d..ee97230d67 100644 --- a/src/gui/graphics/drawables/juce_DrawableRectangle.h +++ b/src/gui/graphics/drawables/juce_DrawableRectangle.h @@ -74,7 +74,7 @@ public: //============================================================================== /** Internally-used class for wrapping a DrawableRectangle's state into a ValueTree. */ - class ValueTreeWrapper : public FillAndStrokeState + class ValueTreeWrapper : public DrawableShape::FillAndStrokeState { public: ValueTreeWrapper (const ValueTree& state); diff --git a/src/gui/graphics/drawables/juce_DrawableShape.h b/src/gui/graphics/drawables/juce_DrawableShape.h index 9ea8667b8b..6147665265 100644 --- a/src/gui/graphics/drawables/juce_DrawableShape.h +++ b/src/gui/graphics/drawables/juce_DrawableShape.h @@ -90,7 +90,7 @@ public: //============================================================================== /** @internal */ - class FillAndStrokeState : public ValueTreeWrapperBase + class FillAndStrokeState : public Drawable::ValueTreeWrapperBase { public: FillAndStrokeState (const ValueTree& state); diff --git a/src/gui/graphics/drawables/juce_DrawableText.h b/src/gui/graphics/drawables/juce_DrawableText.h index 2c0b5aca39..15c9cd199d 100644 --- a/src/gui/graphics/drawables/juce_DrawableText.h +++ b/src/gui/graphics/drawables/juce_DrawableText.h @@ -107,7 +107,7 @@ public: //============================================================================== /** Internally-used class for wrapping a DrawableText's state into a ValueTree. */ - class ValueTreeWrapper : public ValueTreeWrapperBase + class ValueTreeWrapper : public Drawable::ValueTreeWrapperBase { public: ValueTreeWrapper (const ValueTree& state); diff --git a/src/gui/graphics/imaging/juce_Image.cpp b/src/gui/graphics/imaging/juce_Image.cpp index fe96c6de8b..3a74de6a2e 100644 --- a/src/gui/graphics/imaging/juce_Image.cpp +++ b/src/gui/graphics/imaging/juce_Image.cpp @@ -79,7 +79,7 @@ public: return new LowLevelGraphicsSoftwareRenderer (Image (this)); } - SharedImage* clone() + Image::SharedImage* clone() { SoftwareSharedImage* s = new SoftwareSharedImage (format, width, height, false); memcpy (s->imageData, imageData, lineStride * height); @@ -123,7 +123,7 @@ public: return g; } - SharedImage* clone() + Image::SharedImage* clone() { return new SubsectionSharedImage (image->clone(), area); } diff --git a/src/gui/graphics/imaging/juce_Image.h b/src/gui/graphics/imaging/juce_Image.h index 1f4d7a91c5..4e796bc24f 100644 --- a/src/gui/graphics/imaging/juce_Image.h +++ b/src/gui/graphics/imaging/juce_Image.h @@ -401,7 +401,7 @@ public: protected: friend class Image; - friend class Image::BitmapData; + friend class BitmapData; const PixelFormat format; const int width, height; int pixelStride, lineStride; @@ -421,6 +421,9 @@ public: juce_UseDebuggingNewOperator private: + friend class SharedImage; + friend class BitmapData; + ReferenceCountedObjectPtr image; }; diff --git a/src/gui/graphics/imaging/juce_ImageCache.h b/src/gui/graphics/imaging/juce_ImageCache.h index 6e21ee29bc..3a277e24e6 100644 --- a/src/gui/graphics/imaging/juce_ImageCache.h +++ b/src/gui/graphics/imaging/juce_ImageCache.h @@ -116,6 +116,7 @@ public: private: //============================================================================== class Pimpl; + friend class Pimpl; ImageCache(); ImageCache (const ImageCache&); diff --git a/src/native/windows/juce_win32_Threads.cpp b/src/native/windows/juce_win32_Threads.cpp index 5939f6768e..5b9f001f90 100644 --- a/src/native/windows/juce_win32_Threads.cpp +++ b/src/native/windows/juce_win32_Threads.cpp @@ -58,11 +58,11 @@ __int64 juce_InterlockedCompareExchange64 (volatile __int64* value, __int64 newV CriticalSection::CriticalSection() throw() { // (just to check the MS haven't changed this structure and broken things...) -#if _MSC_VER >= 1400 - static_jassert (sizeof (CRITICAL_SECTION) <= sizeof (internal)); -#else + #if JUCE_VC7_OR_EARLIER static_jassert (sizeof (CRITICAL_SECTION) <= 24); -#endif + #else + static_jassert (sizeof (CRITICAL_SECTION) <= sizeof (internal)); + #endif InitializeCriticalSection ((CRITICAL_SECTION*) internal); } diff --git a/src/native/windows/juce_win32_Windowing.cpp b/src/native/windows/juce_win32_Windowing.cpp index 5123bc8ad6..cc5143cf8e 100644 --- a/src/native/windows/juce_win32_Windowing.cpp +++ b/src/native/windows/juce_win32_Windowing.cpp @@ -218,7 +218,7 @@ public: return new LowLevelGraphicsSoftwareRenderer (Image (this)); } - SharedImage* clone() + Image::SharedImage* clone() { WindowsBitmapImage* im = new WindowsBitmapImage (format, width, height, false); diff --git a/src/text/juce_String.cpp b/src/text/juce_String.cpp index 8bdadb955d..453ac3485e 100644 --- a/src/text/juce_String.cpp +++ b/src/text/juce_String.cpp @@ -351,11 +351,11 @@ namespace NumberToStringConverters juce_wchar getDecimalPoint() { -#if JUCE_MSVC && _MSC_VER < 1400 + #if JUCE_VC7_OR_EARLIER static juce_wchar dp = std::_USE (std::locale(), std::numpunct ).decimal_point(); -#else + #else static juce_wchar dp = std::use_facet > (std::locale()).decimal_point(); -#endif + #endif return dp; } @@ -387,15 +387,15 @@ namespace NumberToStringConverters } else { -#if JUCE_WINDOWS - #if (JUCE_MSVC && _MSC_VER <= 1400) || JUCE_MINGW + #if JUCE_WINDOWS + #if JUCE_VC8_OR_EARLIER || JUCE_MINGW len = _snwprintf (buffer, numChars, L"%.9g", n); - #else + #else len = _snwprintf_s (buffer, numChars, _TRUNCATE, L"%.9g", n); - #endif -#else + #endif + #else len = swprintf (buffer, numChars, L"%.9g", n); -#endif + #endif return buffer; } }