| @@ -626,7 +626,7 @@ private: | |||||
| void writeVC6Project (OutputStream& out) | void writeVC6Project (OutputStream& out) | ||||
| { | { | ||||
| String defaultConfig (createConfigNameVC6 (project.getConfiguration (0))); | |||||
| const String defaultConfigName (createConfigNameVC6 (project.getConfiguration (0))); | |||||
| const bool isDLL = project.isAudioPlugin() || project.isBrowserPlugin(); | const bool isDLL = project.isAudioPlugin() || project.isBrowserPlugin(); | ||||
| String targetType, targetCode; | String targetType, targetCode; | ||||
| @@ -641,7 +641,7 @@ private: | |||||
| << "# Microsoft Developer Studio Generated Build File, Format Version 6.00" << newLine | << "# Microsoft Developer Studio Generated Build File, Format Version 6.00" << newLine | ||||
| << "# ** DO NOT EDIT **" << newLine | << "# ** DO NOT EDIT **" << newLine | ||||
| << "# TARGTYPE " << targetType << " " << targetCode << newLine | << "# TARGTYPE " << targetType << " " << targetCode << newLine | ||||
| << "CFG=" << defaultConfig << newLine | |||||
| << "CFG=" << defaultConfigName << newLine | |||||
| << "!MESSAGE This is not a valid makefile. To build this project using NMAKE," << newLine | << "!MESSAGE This is not a valid makefile. To build this project using NMAKE," << newLine | ||||
| << "!MESSAGE use the Export Makefile command and run" << newLine | << "!MESSAGE use the Export Makefile command and run" << newLine | ||||
| << "!MESSAGE " << newLine | << "!MESSAGE " << newLine | ||||
| @@ -650,7 +650,7 @@ private: | |||||
| << "!MESSAGE You can specify a configuration when running NMAKE" << newLine | << "!MESSAGE You can specify a configuration when running NMAKE" << newLine | ||||
| << "!MESSAGE by defining the macro CFG on the command line. For example:" << newLine | << "!MESSAGE by defining the macro CFG on the command line. For example:" << newLine | ||||
| << "!MESSAGE " << newLine | << "!MESSAGE " << newLine | ||||
| << "!MESSAGE NMAKE /f \"" << project.getProjectName() << ".mak\" CFG=\"" << defaultConfig << '"' << newLine | |||||
| << "!MESSAGE NMAKE /f \"" << project.getProjectName() << ".mak\" CFG=\"" << defaultConfigName << '"' << newLine | |||||
| << "!MESSAGE " << newLine | << "!MESSAGE " << newLine | ||||
| << "!MESSAGE Possible choices for configuration are:" << newLine | << "!MESSAGE Possible choices for configuration are:" << newLine | ||||
| << "!MESSAGE " << newLine; | << "!MESSAGE " << newLine; | ||||
| @@ -676,29 +676,31 @@ private: | |||||
| const String configName (createConfigNameVC6 (config)); | const String configName (createConfigNameVC6 (config)); | ||||
| targetList << "# Name \"" << configName << '"' << newLine; | targetList << "# Name \"" << configName << '"' << newLine; | ||||
| const String outFile (windowsStylePath (getConfigTargetPath(config) + "/" + config.getTargetBinaryName().toString() + getTargetBinarySuffix())); | |||||
| const String binariesPath (getConfigTargetPath (config)); | |||||
| const String targetBinary (windowsStylePath (binariesPath + "/" + config.getTargetBinaryName().toString() + getTargetBinarySuffix())); | |||||
| const String optimisationFlag (((int) config.getOptimisationLevel().getValue() <= 1) ? "Od" : (config.getOptimisationLevel() == 2 ? "O2" : "O3")); | const String optimisationFlag (((int) config.getOptimisationLevel().getValue() <= 1) ? "Od" : (config.getOptimisationLevel() == 2 ? "O2" : "O3")); | ||||
| const String defines (getPreprocessorDefs (config, " /D ")); | const String defines (getPreprocessorDefs (config, " /D ")); | ||||
| const bool isDebug = (bool) config.isDebug().getValue(); | const bool isDebug = (bool) config.isDebug().getValue(); | ||||
| const String extraDebugFlags (isDebug ? "/Gm /ZI /GZ" : ""); | const String extraDebugFlags (isDebug ? "/Gm /ZI /GZ" : ""); | ||||
| const String includes (getHeaderSearchPaths (config).joinIntoString (" /I ")); | |||||
| out << (i == 0 ? "!IF" : "!ELSEIF") << " \"$(CFG)\" == \"" << configName << '"' << newLine | out << (i == 0 ? "!IF" : "!ELSEIF") << " \"$(CFG)\" == \"" << configName << '"' << newLine | ||||
| << "# PROP BASE Use_MFC 0" << newLine | << "# PROP BASE Use_MFC 0" << newLine | ||||
| << "# PROP BASE Use_Debug_Libraries " << (isDebug ? "1" : "0") << newLine | << "# PROP BASE Use_Debug_Libraries " << (isDebug ? "1" : "0") << newLine | ||||
| << "# PROP BASE Output_Dir \"" << getConfigTargetPath (config) << '"' << newLine | |||||
| << "# PROP BASE Output_Dir \"" << binariesPath << '"' << newLine | |||||
| << "# PROP BASE Intermediate_Dir \"" << getIntermediatesPath (config) << '"' << newLine | << "# PROP BASE Intermediate_Dir \"" << getIntermediatesPath (config) << '"' << newLine | ||||
| << "# PROP BASE Target_Dir \"\"" << newLine | << "# PROP BASE Target_Dir \"\"" << newLine | ||||
| << "# PROP Use_MFC 0" << newLine | << "# PROP Use_MFC 0" << newLine | ||||
| << "# PROP Use_Debug_Libraries " << (isDebug ? "1" : "0") << newLine | << "# PROP Use_Debug_Libraries " << (isDebug ? "1" : "0") << newLine | ||||
| << "# PROP Output_Dir \"" << getConfigTargetPath (config) << '"' << newLine | |||||
| << "# PROP Output_Dir \"" << binariesPath << '"' << newLine | |||||
| << "# PROP Intermediate_Dir \"" << getIntermediatesPath (config) << '"' << newLine | << "# PROP Intermediate_Dir \"" << getIntermediatesPath (config) << '"' << newLine | ||||
| << "# PROP Ignore_Export_Lib 0" << newLine | << "# PROP Ignore_Export_Lib 0" << newLine | ||||
| << "# PROP Target_Dir \"\"" << newLine | << "# PROP Target_Dir \"\"" << newLine | ||||
| << "# ADD BASE CPP /nologo /W3 /GX /" << optimisationFlag << " /D " << defines | << "# ADD BASE CPP /nologo /W3 /GX /" << optimisationFlag << " /D " << defines | ||||
| << " /YX /FD /c " << extraDebugFlags << " /Zm1024" << newLine | << " /YX /FD /c " << extraDebugFlags << " /Zm1024" << newLine | ||||
| << "# ADD CPP /nologo " << (isDebug ? "/MTd" : "/MT") << " /W3 /GR /GX /" << optimisationFlag | << "# ADD CPP /nologo " << (isDebug ? "/MTd" : "/MT") << " /W3 /GR /GX /" << optimisationFlag | ||||
| << " /I " << includes << " /D " << defines << " /D \"_UNICODE\" /D \"UNICODE\" /FD /c " << extraDebugFlags << " /Zm1024" << newLine; | |||||
| << " /I " << getHeaderSearchPaths (config).joinIntoString (" /I ") | |||||
| << " /D " << defines << " /D \"_UNICODE\" /D \"UNICODE\" /FD /c " << extraDebugFlags | |||||
| << " /Zm1024" << newLine; | |||||
| if (! isDebug) | if (! isDebug) | ||||
| out << "# SUBTRACT CPP /YX" << newLine; | out << "# SUBTRACT CPP /YX" << newLine; | ||||
| @@ -707,7 +709,7 @@ private: | |||||
| out << "# ADD BASE MTL /nologo /D " << defines << " /mktyplib203 /win32" << newLine | out << "# ADD BASE MTL /nologo /D " << defines << " /mktyplib203 /win32" << newLine | ||||
| << "# ADD MTL /nologo /D " << defines << " /mktyplib203 /win32" << newLine; | << "# ADD MTL /nologo /D " << defines << " /mktyplib203 /win32" << newLine; | ||||
| out << "# ADD BASE RSC /l 0x40c /d " << defines << newLine | |||||
| out << "# ADD BASE RSC /l 0x40c /d " << defines << newLine | |||||
| << "# ADD RSC /l 0x40c /d " << defines << newLine | << "# ADD RSC /l 0x40c /d " << defines << newLine | ||||
| << "BSC32=bscmake.exe" << newLine | << "BSC32=bscmake.exe" << newLine | ||||
| << "# ADD BASE BSC32 /nologo" << newLine | << "# ADD BASE BSC32 /nologo" << newLine | ||||
| @@ -717,7 +719,7 @@ private: | |||||
| { | { | ||||
| out << "LIB32=link.exe -lib" << newLine | out << "LIB32=link.exe -lib" << newLine | ||||
| << "# ADD BASE LIB32 /nologo" << newLine | << "# ADD BASE LIB32 /nologo" << newLine | ||||
| << "# ADD LIB32 /nologo /out:\"" << outFile << '"' << newLine; | |||||
| << "# ADD LIB32 /nologo /out:\"" << targetBinary << '"' << newLine; | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -726,7 +728,7 @@ private: | |||||
| << "# ADD LINK32 \"C:\\Program Files\\Microsoft Visual Studio\\VC98\\LIB\\shell32.lib\" " // This is avoid debug information corruption when mixing Platform SDK | << "# ADD LINK32 \"C:\\Program Files\\Microsoft Visual Studio\\VC98\\LIB\\shell32.lib\" " // This is avoid debug information corruption when mixing Platform SDK | ||||
| << "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib " | << "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib " | ||||
| << (isDebug ? " /debug" : "") | << (isDebug ? " /debug" : "") | ||||
| << " /nologo /machine:I386 /out:\"" << outFile << "\" " | |||||
| << " /nologo /machine:I386 /out:\"" << targetBinary << "\" " | |||||
| << (isDLL ? "/dll" : (project.isCommandLineApp() ? "/subsystem:console" | << (isDLL ? "/dll" : (project.isCommandLineApp() ? "/subsystem:console" | ||||
| : "/subsystem:windows")) << newLine; | : "/subsystem:windows")) << newLine; | ||||
| } | } | ||||
| @@ -43,7 +43,7 @@ | |||||
| #define JUCE_MAJOR_VERSION 1 | #define JUCE_MAJOR_VERSION 1 | ||||
| #define JUCE_MINOR_VERSION 51 | #define JUCE_MINOR_VERSION 51 | ||||
| #define JUCE_BUILDNUMBER 10 | |||||
| #define JUCE_BUILDNUMBER 11 | |||||
| #define JUCE_VERSION ((JUCE_MAJOR_VERSION << 16) + (JUCE_MINOR_VERSION << 8) + JUCE_BUILDNUMBER) | #define JUCE_VERSION ((JUCE_MAJOR_VERSION << 16) + (JUCE_MINOR_VERSION << 8) + JUCE_BUILDNUMBER) | ||||
| @@ -2050,7 +2050,7 @@ public: | |||||
| while (e != end) | while (e != end) | ||||
| { | { | ||||
| if (elementToLookFor == *e) | if (elementToLookFor == *e) | ||||
| return (int) (e - data.elements.getData()); | |||||
| return static_cast <int> (e - data.elements.getData()); | |||||
| ++e; | ++e; | ||||
| } | } | ||||
| @@ -2310,7 +2310,7 @@ public: | |||||
| { | { | ||||
| if (valueToRemove == *e) | if (valueToRemove == *e) | ||||
| { | { | ||||
| remove ((int) (e - data.elements.getData())); | |||||
| remove (static_cast <int> (e - data.elements.getData())); | |||||
| break; | break; | ||||
| } | } | ||||
| @@ -2326,7 +2326,7 @@ public: | |||||
| if (endIndex > startIndex) | if (endIndex > startIndex) | ||||
| { | { | ||||
| ElementType* e = data.elements + startIndex; | |||||
| ElementType* const e = data.elements + startIndex; | |||||
| numberToRemove = endIndex - startIndex; | numberToRemove = endIndex - startIndex; | ||||
| for (int i = 0; i < numberToRemove; ++i) | for (int i = 0; i < numberToRemove; ++i) | ||||
| @@ -2495,82 +2495,109 @@ private: | |||||
| class MemoryBlock; | class MemoryBlock; | ||||
| class JUCE_API BitArray | |||||
| class JUCE_API BigInteger | |||||
| { | { | ||||
| public: | public: | ||||
| BitArray() throw(); | |||||
| BigInteger(); | |||||
| BitArray (const unsigned int value) throw(); | |||||
| BigInteger (unsigned int value); | |||||
| BitArray (const int value) throw(); | |||||
| BigInteger (int value); | |||||
| BitArray (int64 value) throw(); | |||||
| BigInteger (int64 value); | |||||
| BitArray (const BitArray& other) throw(); | |||||
| BigInteger (const BigInteger& other); | |||||
| ~BitArray() throw(); | |||||
| ~BigInteger(); | |||||
| BitArray& operator= (const BitArray& other) throw(); | |||||
| BigInteger& operator= (const BigInteger& other); | |||||
| bool operator== (const BitArray& other) const throw(); | |||||
| bool operator!= (const BitArray& other) const throw(); | |||||
| void swapWith (BigInteger& other) throw(); | |||||
| void clear() throw(); | |||||
| void clearBit (const int bitNumber) throw(); | |||||
| void setBit (const int bitNumber) throw(); | |||||
| void setBit (const int bitNumber, | |||||
| const bool shouldBeSet) throw(); | |||||
| void setRange (int startBit, | |||||
| int numBits, | |||||
| const bool shouldBeSet) throw(); | |||||
| void insertBit (const int bitNumber, | |||||
| const bool shouldBeSet) throw(); | |||||
| bool operator[] (const int bit) const throw(); | |||||
| bool operator[] (int bit) const throw(); | |||||
| bool isEmpty() const throw(); | |||||
| bool isZero() const throw(); | |||||
| const BitArray getBitRange (int startBit, int numBits) const throw(); | |||||
| bool isOne() const throw(); | |||||
| int getBitRangeAsInt (int startBit, int numBits) const throw(); | |||||
| int toInteger() const throw(); | |||||
| void setBitRangeAsInt (int startBit, int numBits, | |||||
| unsigned int valueToSet) throw(); | |||||
| void clear(); | |||||
| void orWith (const BitArray& other) throw(); | |||||
| void clearBit (int bitNumber) throw(); | |||||
| void andWith (const BitArray& other) throw(); | |||||
| void setBit (int bitNumber); | |||||
| void xorWith (const BitArray& other) throw(); | |||||
| void setBit (int bitNumber, bool shouldBeSet); | |||||
| void add (const BitArray& other) throw(); | |||||
| void setRange (int startBit, int numBits, bool shouldBeSet); | |||||
| void subtract (const BitArray& other) throw(); | |||||
| void insertBit (int bitNumber, bool shouldBeSet); | |||||
| void multiplyBy (const BitArray& other) throw(); | |||||
| const BigInteger getBitRange (int startBit, int numBits) const; | |||||
| void divideBy (const BitArray& divisor, BitArray& remainder) throw(); | |||||
| int getBitRangeAsInt (int startBit, int numBits) const throw(); | |||||
| const BitArray findGreatestCommonDivisor (BitArray other) const throw(); | |||||
| void setBitRangeAsInt (int startBit, int numBits, unsigned int valueToSet); | |||||
| void modulo (const BitArray& divisor) throw(); | |||||
| void shiftBits (int howManyBitsLeft, int startBit); | |||||
| void exponentModulo (const BitArray& exponent, const BitArray& modulus) throw(); | |||||
| int countNumberOfSetBits() const throw(); | |||||
| void inverseModulo (const BitArray& modulus) throw(); | |||||
| int findNextSetBit (int startIndex = 0) const throw(); | |||||
| void shiftBits (int howManyBitsLeft, | |||||
| int startBit = 0) throw(); | |||||
| int findNextClearBit (int startIndex = 0) const throw(); | |||||
| int compare (const BitArray& other) const throw(); | |||||
| int getHighestBit() const throw(); | |||||
| int compareAbsolute (const BitArray& other) const throw(); | |||||
| // All the standard arithmetic ops... | |||||
| BigInteger& operator+= (const BigInteger& other); | |||||
| BigInteger& operator-= (const BigInteger& other); | |||||
| BigInteger& operator*= (const BigInteger& other); | |||||
| BigInteger& operator/= (const BigInteger& other); | |||||
| BigInteger& operator|= (const BigInteger& other); | |||||
| BigInteger& operator&= (const BigInteger& other); | |||||
| BigInteger& operator^= (const BigInteger& other); | |||||
| BigInteger& operator%= (const BigInteger& other); | |||||
| BigInteger& operator<<= (int numBitsToShift); | |||||
| BigInteger& operator>>= (int numBitsToShift); | |||||
| BigInteger& operator++(); | |||||
| BigInteger& operator--(); | |||||
| const BigInteger operator++ (int); | |||||
| const BigInteger operator-- (int); | |||||
| const BigInteger operator-() const; | |||||
| const BigInteger operator+ (const BigInteger& other) const; | |||||
| const BigInteger operator- (const BigInteger& other) const; | |||||
| const BigInteger operator* (const BigInteger& other) const; | |||||
| const BigInteger operator/ (const BigInteger& other) const; | |||||
| const BigInteger operator| (const BigInteger& other) const; | |||||
| const BigInteger operator& (const BigInteger& other) const; | |||||
| const BigInteger operator^ (const BigInteger& other) const; | |||||
| const BigInteger operator% (const BigInteger& other) const; | |||||
| const BigInteger operator<< (int numBitsToShift) const; | |||||
| const BigInteger operator>> (int numBitsToShift) const; | |||||
| bool operator== (const BigInteger& other) const throw(); | |||||
| bool operator!= (const BigInteger& other) const throw(); | |||||
| bool operator< (const BigInteger& other) const throw(); | |||||
| bool operator<= (const BigInteger& other) const throw(); | |||||
| bool operator> (const BigInteger& other) const throw(); | |||||
| bool operator>= (const BigInteger& other) const throw(); | |||||
| int compare (const BigInteger& other) const throw(); | |||||
| int compareAbsolute (const BigInteger& other) const throw(); | |||||
| void divideBy (const BigInteger& divisor, BigInteger& remainder); | |||||
| const BigInteger findGreatestCommonDivisor (BigInteger other) const; | |||||
| void exponentModulo (const BigInteger& exponent, const BigInteger& modulus); | |||||
| void inverseModulo (const BigInteger& modulus); | |||||
| bool isNegative() const throw(); | bool isNegative() const throw(); | ||||
| @@ -2578,32 +2605,29 @@ public: | |||||
| void negate() throw(); | void negate() throw(); | ||||
| int countNumberOfSetBits() const throw(); | |||||
| int findNextSetBit (int startIndex = 0) const throw(); | |||||
| int findNextClearBit (int startIndex = 0) const throw(); | |||||
| int getHighestBit() const throw(); | |||||
| const String toString (const int base, const int minimumNumCharacters = 1) const throw(); | |||||
| const String toString (int base, int minimumNumCharacters = 1) const; | |||||
| void parseString (const String& text, | |||||
| const int base) throw(); | |||||
| void parseString (const String& text, int base); | |||||
| const MemoryBlock toMemoryBlock() const throw(); | |||||
| const MemoryBlock toMemoryBlock() const; | |||||
| void loadFromMemoryBlock (const MemoryBlock& data) throw(); | |||||
| void loadFromMemoryBlock (const MemoryBlock& data); | |||||
| juce_UseDebuggingNewOperator | juce_UseDebuggingNewOperator | ||||
| private: | private: | ||||
| void ensureSize (const int numVals) throw(); | |||||
| HeapBlock <unsigned int> values; | HeapBlock <unsigned int> values; | ||||
| int numValues, highestBit; | int numValues, highestBit; | ||||
| bool negative; | bool negative; | ||||
| void ensureSize (int numVals); | |||||
| static const BigInteger simpleGCD (BigInteger* m, BigInteger* n); | |||||
| }; | }; | ||||
| OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const BigInteger& value); | |||||
| typedef BigInteger BitArray; | |||||
| #endif // __JUCE_BITARRAY_JUCEHEADER__ | #endif // __JUCE_BITARRAY_JUCEHEADER__ | ||||
| /*** End of inlined file: juce_BitArray.h ***/ | /*** End of inlined file: juce_BitArray.h ***/ | ||||
| @@ -3470,7 +3494,7 @@ public: | |||||
| while (e != end) | while (e != end) | ||||
| { | { | ||||
| if (objectToLookFor == *e) | if (objectToLookFor == *e) | ||||
| return (int) (e - data.elements.getData()); | |||||
| return static_cast <int> (e - data.elements.getData()); | |||||
| ++e; | ++e; | ||||
| } | } | ||||
| @@ -3666,7 +3690,7 @@ public: | |||||
| { | { | ||||
| if (objectToRemove == *e) | if (objectToRemove == *e) | ||||
| { | { | ||||
| remove ((int) (e - data.elements.getData()), deleteObject); | |||||
| remove (static_cast <int> (e - data.elements.getData()), deleteObject); | |||||
| break; | break; | ||||
| } | } | ||||
| @@ -4947,7 +4971,7 @@ public: | |||||
| while (e != end) | while (e != end) | ||||
| { | { | ||||
| if (objectToLookFor == *e) | if (objectToLookFor == *e) | ||||
| return (int) (e - data.elements.getData()); | |||||
| return static_cast <int> (e - data.elements.getData()); | |||||
| ++e; | ++e; | ||||
| } | } | ||||
| @@ -7067,9 +7091,9 @@ public: | |||||
| bool nextBool() throw(); | bool nextBool() throw(); | ||||
| const BitArray nextLargeNumber (const BitArray& maximumValue) throw(); | |||||
| const BigInteger nextLargeNumber (const BigInteger& maximumValue); | |||||
| void fillBitsRandomly (BitArray& arrayToChange, int startBit, int numBits) throw(); | |||||
| void fillBitsRandomly (BigInteger& arrayToChange, int startBit, int numBits); | |||||
| static Random& getSystemRandom() throw(); | static Random& getSystemRandom() throw(); | ||||
| @@ -7503,13 +7527,12 @@ class JUCE_API Primes | |||||
| { | { | ||||
| public: | public: | ||||
| static const BitArray createProbablePrime (int bitLength, | |||||
| int certainty, | |||||
| const int* randomSeeds = 0, | |||||
| int numRandomSeeds = 0) throw(); | |||||
| static const BigInteger createProbablePrime (int bitLength, | |||||
| int certainty, | |||||
| const int* randomSeeds = 0, | |||||
| int numRandomSeeds = 0); | |||||
| static bool isProbablyPrime (const BitArray& number, | |||||
| int certainty) throw(); | |||||
| static bool isProbablyPrime (const BigInteger& number, int certainty); | |||||
| }; | }; | ||||
| #endif // __JUCE_PRIMES_JUCEHEADER__ | #endif // __JUCE_PRIMES_JUCEHEADER__ | ||||
| @@ -7527,26 +7550,26 @@ class JUCE_API RSAKey | |||||
| { | { | ||||
| public: | public: | ||||
| RSAKey() throw(); | |||||
| RSAKey(); | |||||
| RSAKey (const String& stringRepresentation) throw(); | |||||
| RSAKey (const String& stringRepresentation); | |||||
| ~RSAKey() throw(); | |||||
| ~RSAKey(); | |||||
| const String toString() const throw(); | |||||
| const String toString() const; | |||||
| bool applyToValue (BitArray& value) const throw(); | |||||
| bool applyToValue (BigInteger& value) const; | |||||
| static void createKeyPair (RSAKey& publicKey, | static void createKeyPair (RSAKey& publicKey, | ||||
| RSAKey& privateKey, | RSAKey& privateKey, | ||||
| const int numBits, | |||||
| int numBits, | |||||
| const int* randomSeeds = 0, | const int* randomSeeds = 0, | ||||
| const int numRandomSeeds = 0) throw(); | |||||
| int numRandomSeeds = 0); | |||||
| juce_UseDebuggingNewOperator | juce_UseDebuggingNewOperator | ||||
| protected: | protected: | ||||
| BitArray part1, part2; | |||||
| BigInteger part1, part2; | |||||
| }; | }; | ||||
| #endif // __JUCE_RSAKEY_JUCEHEADER__ | #endif // __JUCE_RSAKEY_JUCEHEADER__ | ||||
| @@ -14595,8 +14618,8 @@ public: | |||||
| virtual int getDefaultBufferSize() = 0; | virtual int getDefaultBufferSize() = 0; | ||||
| virtual const String open (const BitArray& inputChannels, | |||||
| const BitArray& outputChannels, | |||||
| virtual const String open (const BigInteger& inputChannels, | |||||
| const BigInteger& outputChannels, | |||||
| double sampleRate, | double sampleRate, | ||||
| int bufferSizeSamples) = 0; | int bufferSizeSamples) = 0; | ||||
| @@ -14618,9 +14641,9 @@ public: | |||||
| virtual int getCurrentBitDepth() = 0; | virtual int getCurrentBitDepth() = 0; | ||||
| virtual const BitArray getActiveOutputChannels() const = 0; | |||||
| virtual const BigInteger getActiveOutputChannels() const = 0; | |||||
| virtual const BitArray getActiveInputChannels() const = 0; | |||||
| virtual const BigInteger getActiveInputChannels() const = 0; | |||||
| virtual int getOutputLatencyInSamples() = 0; | virtual int getOutputLatencyInSamples() = 0; | ||||
| @@ -15068,7 +15091,7 @@ public: | |||||
| private: | private: | ||||
| VoidArray inputs; | VoidArray inputs; | ||||
| BitArray inputsToDelete; | |||||
| BigInteger inputsToDelete; | |||||
| CriticalSection lock; | CriticalSection lock; | ||||
| AudioSampleBuffer tempBuffer; | AudioSampleBuffer tempBuffer; | ||||
| double currentSampleRate; | double currentSampleRate; | ||||
| @@ -17013,11 +17036,11 @@ public: | |||||
| int bufferSize; | int bufferSize; | ||||
| BitArray inputChannels; | |||||
| BigInteger inputChannels; | |||||
| bool useDefaultInputChannels; | bool useDefaultInputChannels; | ||||
| BitArray outputChannels; | |||||
| BigInteger outputChannels; | |||||
| bool useDefaultOutputChannels; | bool useDefaultOutputChannels; | ||||
| }; | }; | ||||
| @@ -17094,7 +17117,7 @@ private: | |||||
| SortedSet <AudioIODeviceCallback*> callbacks; | SortedSet <AudioIODeviceCallback*> callbacks; | ||||
| int numInputChansNeeded, numOutputChansNeeded; | int numInputChansNeeded, numOutputChansNeeded; | ||||
| String currentDeviceType; | String currentDeviceType; | ||||
| BitArray inputChannels, outputChannels; | |||||
| BigInteger inputChannels, outputChannels; | |||||
| ScopedPointer <XmlElement> lastExplicitSettings; | ScopedPointer <XmlElement> lastExplicitSettings; | ||||
| mutable bool listNeedsScanning; | mutable bool listNeedsScanning; | ||||
| bool useInputNames; | bool useInputNames; | ||||
| @@ -17147,7 +17170,7 @@ private: | |||||
| void handleIncomingMidiMessageInt (MidiInput* source, const MidiMessage& message); | void handleIncomingMidiMessageInt (MidiInput* source, const MidiMessage& message); | ||||
| const String restartDevice (int blockSizeToUse, double sampleRateToUse, | const String restartDevice (int blockSizeToUse, double sampleRateToUse, | ||||
| const BitArray& ins, const BitArray& outs); | |||||
| const BigInteger& ins, const BigInteger& outs); | |||||
| void stopDevice(); | void stopDevice(); | ||||
| void updateXml(); | void updateXml(); | ||||
| @@ -17810,7 +17833,7 @@ private: | |||||
| CriticalSection callbackLock, listenerLock; | CriticalSection callbackLock, listenerLock; | ||||
| #ifdef JUCE_DEBUG | #ifdef JUCE_DEBUG | ||||
| BitArray changingParams; | |||||
| BigInteger changingParams; | |||||
| #endif | #endif | ||||
| AudioProcessor (const AudioProcessor&); | AudioProcessor (const AudioProcessor&); | ||||
| @@ -19299,7 +19322,7 @@ public: | |||||
| SamplerSound (const String& name, | SamplerSound (const String& name, | ||||
| AudioFormatReader& source, | AudioFormatReader& source, | ||||
| const BitArray& midiNotes, | |||||
| const BigInteger& midiNotes, | |||||
| const int midiNoteForNormalPitch, | const int midiNoteForNormalPitch, | ||||
| const double attackTimeSecs, | const double attackTimeSecs, | ||||
| const double releaseTimeSecs, | const double releaseTimeSecs, | ||||
| @@ -19322,7 +19345,7 @@ private: | |||||
| String name; | String name; | ||||
| ScopedPointer <AudioSampleBuffer> data; | ScopedPointer <AudioSampleBuffer> data; | ||||
| double sourceSampleRate; | double sourceSampleRate; | ||||
| BitArray midiNotes; | |||||
| BigInteger midiNotes; | |||||
| int length, attackSamples, releaseSamples; | int length, attackSamples, releaseSamples; | ||||
| int midiRootNote; | int midiRootNote; | ||||
| }; | }; | ||||
| @@ -22459,7 +22482,7 @@ public: | |||||
| juce_UseDebuggingNewOperator | juce_UseDebuggingNewOperator | ||||
| protected: | protected: | ||||
| virtual const BitArray getRoots (StringArray& rootNames, StringArray& rootPaths); | |||||
| virtual const BigInteger getRoots (StringArray& rootNames, StringArray& rootPaths); | |||||
| private: | private: | ||||
| @@ -26584,7 +26607,7 @@ private: | |||||
| int midiChannel, midiInChannelMask; | int midiChannel, midiInChannelMask; | ||||
| float velocity; | float velocity; | ||||
| int noteUnderMouse, mouseDownNote; | int noteUnderMouse, mouseDownNote; | ||||
| BitArray keysPressed, keysCurrentlyDrawnDown; | |||||
| BigInteger keysPressed, keysCurrentlyDrawnDown; | |||||
| int rangeStart, rangeEnd, firstKey; | int rangeStart, rangeEnd, firstKey; | ||||
| bool canScroll, mouseDragging, useMousePositionForVelocity; | bool canScroll, mouseDragging, useMousePositionForVelocity; | ||||
| @@ -99,7 +99,7 @@ void MixerAudioSource::removeInputSource (AudioSource* input, const bool deleteI | |||||
| void MixerAudioSource::removeAllInputs() | void MixerAudioSource::removeAllInputs() | ||||
| { | { | ||||
| VoidArray inputsCopy; | VoidArray inputsCopy; | ||||
| BitArray inputsToDeleteCopy; | |||||
| BigInteger inputsToDeleteCopy; | |||||
| { | { | ||||
| const ScopedLock sl (lock); | const ScopedLock sl (lock); | ||||
| @@ -112,7 +112,7 @@ public: | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| VoidArray inputs; | VoidArray inputs; | ||||
| BitArray inputsToDelete; | |||||
| BigInteger inputsToDelete; | |||||
| CriticalSection lock; | CriticalSection lock; | ||||
| AudioSampleBuffer tempBuffer; | AudioSampleBuffer tempBuffer; | ||||
| double currentSampleRate; | double currentSampleRate; | ||||
| @@ -124,7 +124,7 @@ public: | |||||
| The bits that are set in this array indicate the channels of the | The bits that are set in this array indicate the channels of the | ||||
| input device that are active. | input device that are active. | ||||
| */ | */ | ||||
| BitArray inputChannels; | |||||
| BigInteger inputChannels; | |||||
| /** If this is true, it indicates that the inputChannels array | /** If this is true, it indicates that the inputChannels array | ||||
| should be ignored, and instead, the device's default channels | should be ignored, and instead, the device's default channels | ||||
| @@ -136,7 +136,7 @@ public: | |||||
| The bits that are set in this array indicate the channels of the | The bits that are set in this array indicate the channels of the | ||||
| input device that are active. | input device that are active. | ||||
| */ | */ | ||||
| BitArray outputChannels; | |||||
| BigInteger outputChannels; | |||||
| /** If this is true, it indicates that the outputChannels array | /** If this is true, it indicates that the outputChannels array | ||||
| should be ignored, and instead, the device's default channels | should be ignored, and instead, the device's default channels | ||||
| @@ -426,7 +426,7 @@ private: | |||||
| SortedSet <AudioIODeviceCallback*> callbacks; | SortedSet <AudioIODeviceCallback*> callbacks; | ||||
| int numInputChansNeeded, numOutputChansNeeded; | int numInputChansNeeded, numOutputChansNeeded; | ||||
| String currentDeviceType; | String currentDeviceType; | ||||
| BitArray inputChannels, outputChannels; | |||||
| BigInteger inputChannels, outputChannels; | |||||
| ScopedPointer <XmlElement> lastExplicitSettings; | ScopedPointer <XmlElement> lastExplicitSettings; | ||||
| mutable bool listNeedsScanning; | mutable bool listNeedsScanning; | ||||
| bool useInputNames; | bool useInputNames; | ||||
| @@ -480,7 +480,7 @@ private: | |||||
| void handleIncomingMidiMessageInt (MidiInput* source, const MidiMessage& message); | void handleIncomingMidiMessageInt (MidiInput* source, const MidiMessage& message); | ||||
| const String restartDevice (int blockSizeToUse, double sampleRateToUse, | const String restartDevice (int blockSizeToUse, double sampleRateToUse, | ||||
| const BitArray& ins, const BitArray& outs); | |||||
| const BigInteger& ins, const BigInteger& outs); | |||||
| void stopDevice(); | void stopDevice(); | ||||
| void updateXml(); | void updateXml(); | ||||
| @@ -203,9 +203,9 @@ public: | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Tries to open the device ready to play. | /** Tries to open the device ready to play. | ||||
| @param inputChannels a BitArray in which a set bit indicates that the corresponding | |||||
| @param inputChannels a BigInteger in which a set bit indicates that the corresponding | |||||
| input channel should be enabled | input channel should be enabled | ||||
| @param outputChannels a BitArray in which a set bit indicates that the corresponding | |||||
| @param outputChannels a BigInteger in which a set bit indicates that the corresponding | |||||
| output channel should be enabled | output channel should be enabled | ||||
| @param sampleRate the sample rate to try to use - to find out which rates are | @param sampleRate the sample rate to try to use - to find out which rates are | ||||
| available, see getNumSampleRates() and getSampleRate() | available, see getNumSampleRates() and getSampleRate() | ||||
| @@ -215,8 +215,8 @@ public: | |||||
| opening the device | opening the device | ||||
| @see close | @see close | ||||
| */ | */ | ||||
| virtual const String open (const BitArray& inputChannels, | |||||
| const BitArray& outputChannels, | |||||
| virtual const String open (const BigInteger& inputChannels, | |||||
| const BigInteger& outputChannels, | |||||
| double sampleRate, | double sampleRate, | ||||
| int bufferSizeSamples) = 0; | int bufferSizeSamples) = 0; | ||||
| @@ -279,13 +279,13 @@ public: | |||||
| enabled. | enabled. | ||||
| @see getOutputChannelNames | @see getOutputChannelNames | ||||
| */ | */ | ||||
| virtual const BitArray getActiveOutputChannels() const = 0; | |||||
| virtual const BigInteger getActiveOutputChannels() const = 0; | |||||
| /** Returns a mask showing which of the available input channels are currently | /** Returns a mask showing which of the available input channels are currently | ||||
| enabled. | enabled. | ||||
| @see getInputChannelNames | @see getInputChannelNames | ||||
| */ | */ | ||||
| virtual const BitArray getActiveInputChannels() const = 0; | |||||
| virtual const BigInteger getActiveInputChannels() const = 0; | |||||
| /** Returns the device's output latency. | /** Returns the device's output latency. | ||||
| @@ -79,7 +79,7 @@ void MidiBuffer::clear (const int startSample, | |||||
| if (end > start) | if (end > start) | ||||
| { | { | ||||
| const size_t bytesToMove = (size_t) (bytesUsed - (end - getData())); | |||||
| const int bytesToMove = bytesUsed - (int) (end - getData()); | |||||
| if (bytesToMove > 0) | if (bytesToMove > 0) | ||||
| memmove (start, end, bytesToMove); | memmove (start, end, bytesToMove); | ||||
| @@ -137,7 +137,7 @@ void MidiBuffer::addEvent (const uint8* const newData, | |||||
| data.ensureSize ((spaceNeeded + spaceNeeded / 2 + 8) & ~7); | data.ensureSize ((spaceNeeded + spaceNeeded / 2 + 8) & ~7); | ||||
| uint8* d = findEventAfter (getData(), sampleNumber); | uint8* d = findEventAfter (getData(), sampleNumber); | ||||
| const size_t bytesToMove = (size_t) (bytesUsed - (d - getData())); | |||||
| const int bytesToMove = bytesUsed - (int) (d - getData()); | |||||
| if (bytesToMove > 0) | if (bytesToMove > 0) | ||||
| memmove (d + numBytes + 6, | memmove (d + numBytes + 6, | ||||
| @@ -56,7 +56,7 @@ void AudioPluginFormatManager::addDefaultFormats() | |||||
| // you should only call this method once! | // you should only call this method once! | ||||
| for (int i = formats.size(); --i >= 0;) | for (int i = formats.size(); --i >= 0;) | ||||
| { | { | ||||
| #if JUCE_PLUGINHOST_VST | |||||
| #if JUCE_PLUGINHOST_VST && ! (JUCE_MAC && JUCE_64BIT) | |||||
| jassert (dynamic_cast <VSTPluginFormat*> (formats[i]) == 0); | jassert (dynamic_cast <VSTPluginFormat*> (formats[i]) == 0); | ||||
| #endif | #endif | ||||
| @@ -78,7 +78,7 @@ void AudioPluginFormatManager::addDefaultFormats() | |||||
| formats.add (new AudioUnitPluginFormat()); | formats.add (new AudioUnitPluginFormat()); | ||||
| #endif | #endif | ||||
| #if JUCE_PLUGINHOST_VST | |||||
| #if JUCE_PLUGINHOST_VST && ! (JUCE_MAC && JUCE_64BIT) | |||||
| formats.add (new VSTPluginFormat()); | formats.add (new VSTPluginFormat()); | ||||
| #endif | #endif | ||||
| @@ -579,7 +579,7 @@ private: | |||||
| CriticalSection callbackLock, listenerLock; | CriticalSection callbackLock, listenerLock; | ||||
| #ifdef JUCE_DEBUG | #ifdef JUCE_DEBUG | ||||
| BitArray changingParams; | |||||
| BigInteger changingParams; | |||||
| #endif | #endif | ||||
| AudioProcessor (const AudioProcessor&); | AudioProcessor (const AudioProcessor&); | ||||
| @@ -34,7 +34,7 @@ BEGIN_JUCE_NAMESPACE | |||||
| //============================================================================== | //============================================================================== | ||||
| SamplerSound::SamplerSound (const String& name_, | SamplerSound::SamplerSound (const String& name_, | ||||
| AudioFormatReader& source, | AudioFormatReader& source, | ||||
| const BitArray& midiNotes_, | |||||
| const BigInteger& midiNotes_, | |||||
| const int midiNoteForNormalPitch, | const int midiNoteForNormalPitch, | ||||
| const double attackTimeSecs, | const double attackTimeSecs, | ||||
| const double releaseTimeSecs, | const double releaseTimeSecs, | ||||
| @@ -66,7 +66,7 @@ public: | |||||
| */ | */ | ||||
| SamplerSound (const String& name, | SamplerSound (const String& name, | ||||
| AudioFormatReader& source, | AudioFormatReader& source, | ||||
| const BitArray& midiNotes, | |||||
| const BigInteger& midiNotes, | |||||
| const int midiNoteForNormalPitch, | const int midiNoteForNormalPitch, | ||||
| const double attackTimeSecs, | const double attackTimeSecs, | ||||
| const double releaseTimeSecs, | const double releaseTimeSecs, | ||||
| @@ -99,7 +99,7 @@ private: | |||||
| String name; | String name; | ||||
| ScopedPointer <AudioSampleBuffer> data; | ScopedPointer <AudioSampleBuffer> data; | ||||
| double sourceSampleRate; | double sourceSampleRate; | ||||
| BitArray midiNotes; | |||||
| BigInteger midiNotes; | |||||
| int length, attackSamples, releaseSamples; | int length, attackSamples, releaseSamples; | ||||
| int midiRootNote; | int midiRootNote; | ||||
| }; | }; | ||||
| @@ -288,7 +288,7 @@ public: | |||||
| while (e != end) | while (e != end) | ||||
| { | { | ||||
| if (elementToLookFor == *e) | if (elementToLookFor == *e) | ||||
| return (int) (e - data.elements.getData()); | |||||
| return static_cast <int> (e - data.elements.getData()); | |||||
| ++e; | ++e; | ||||
| } | } | ||||
| @@ -683,7 +683,7 @@ public: | |||||
| { | { | ||||
| if (valueToRemove == *e) | if (valueToRemove == *e) | ||||
| { | { | ||||
| remove ((int) (e - data.elements.getData())); | |||||
| remove (static_cast <int> (e - data.elements.getData())); | |||||
| break; | break; | ||||
| } | } | ||||
| @@ -711,7 +711,7 @@ public: | |||||
| if (endIndex > startIndex) | if (endIndex > startIndex) | ||||
| { | { | ||||
| ElementType* e = data.elements + startIndex; | |||||
| ElementType* const e = data.elements + startIndex; | |||||
| numberToRemove = endIndex - startIndex; | numberToRemove = endIndex - startIndex; | ||||
| for (int i = 0; i < numberToRemove; ++i) | for (int i = 0; i < numberToRemove; ++i) | ||||
| @@ -27,77 +27,89 @@ | |||||
| #define __JUCE_BITARRAY_JUCEHEADER__ | #define __JUCE_BITARRAY_JUCEHEADER__ | ||||
| #include "../text/juce_String.h" | #include "../text/juce_String.h" | ||||
| #include "juce_Array.h" | |||||
| #include "juce_HeapBlock.h" | #include "juce_HeapBlock.h" | ||||
| class MemoryBlock; | class MemoryBlock; | ||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| An array of on/off bits, also usable to store large binary integers. | |||||
| An arbitrarily large integer class. | |||||
| A BitArray acts like an arbitrarily large integer whose bits can be set or | |||||
| cleared, and some basic mathematical operations can be done on the number as | |||||
| a whole. | |||||
| A BigInteger can be used in a similar way to a normal integer, but has no size | |||||
| limit (except for memory and performance constraints). | |||||
| Negative values are possible, but the value isn't stored as 2s-complement, so | |||||
| be careful if you use negative values and look at the values of individual bits. | |||||
| */ | */ | ||||
| class JUCE_API BitArray | |||||
| class JUCE_API BigInteger | |||||
| { | { | ||||
| public: | public: | ||||
| //============================================================================== | //============================================================================== | ||||
| /** Creates an empty BitArray */ | |||||
| BitArray() throw(); | |||||
| /** Creates an empty BigInteger */ | |||||
| BigInteger(); | |||||
| /** Creates a BitArray containing an integer value in its low bits. | |||||
| /** Creates a BigInteger containing an integer value in its low bits. | |||||
| The low 32 bits of the array are initialised with this value. | |||||
| The low 32 bits of the number are initialised with this value. | |||||
| */ | */ | ||||
| BitArray (const unsigned int value) throw(); | |||||
| BigInteger (unsigned int value); | |||||
| /** Creates a BitArray containing an integer value in its low bits. | |||||
| /** Creates a BigInteger containing an integer value in its low bits. | |||||
| The low 32 bits of the array are initialised with the absolute value | |||||
| The low 32 bits of the number are initialised with the absolute value | |||||
| passed in, and its sign is set to reflect the sign of the number. | passed in, and its sign is set to reflect the sign of the number. | ||||
| */ | */ | ||||
| BitArray (const int value) throw(); | |||||
| BigInteger (int value); | |||||
| /** Creates a BitArray containing an integer value in its low bits. | |||||
| /** Creates a BigInteger containing an integer value in its low bits. | |||||
| The low 64 bits of the array are initialised with the absolute value | |||||
| The low 64 bits of the number are initialised with the absolute value | |||||
| passed in, and its sign is set to reflect the sign of the number. | passed in, and its sign is set to reflect the sign of the number. | ||||
| */ | */ | ||||
| BitArray (int64 value) throw(); | |||||
| BigInteger (int64 value); | |||||
| /** Creates a copy of another BitArray. */ | |||||
| BitArray (const BitArray& other) throw(); | |||||
| /** Creates a copy of another BigInteger. */ | |||||
| BigInteger (const BigInteger& other); | |||||
| /** Destructor. */ | /** Destructor. */ | ||||
| ~BitArray() throw(); | |||||
| ~BigInteger(); | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Copies another BitArray onto this one. */ | |||||
| BitArray& operator= (const BitArray& other) throw(); | |||||
| /** Copies another BigInteger onto this one. */ | |||||
| BigInteger& operator= (const BigInteger& other); | |||||
| /** Two arrays are the same if the same bits are set. */ | |||||
| bool operator== (const BitArray& other) const throw(); | |||||
| /** Two arrays are the same if the same bits are set. */ | |||||
| bool operator!= (const BitArray& other) const throw(); | |||||
| /** Swaps the internal contents of this with another object. */ | |||||
| void swapWith (BigInteger& other) throw(); | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Clears all bits in the BitArray to 0. */ | |||||
| void clear() throw(); | |||||
| /** Returns the value of a specified bit in the number. | |||||
| If the index is out-of-range, the result will be false. | |||||
| */ | |||||
| bool operator[] (int bit) const throw(); | |||||
| /** Clears a particular bit in the array. */ | |||||
| void clearBit (const int bitNumber) throw(); | |||||
| /** Returns true if no bits are set. */ | |||||
| bool isZero() const throw(); | |||||
| /** Sets a specified bit to 1. | |||||
| /** Returns true if the value is 1. */ | |||||
| bool isOne() const throw(); | |||||
| If the bit number is high, this will grow the array to accomodate it. | |||||
| /** Attempts to get the lowest bits of the value as an integer. | |||||
| If the value is bigger than the integer limits, this will return only the lower bits. | |||||
| */ | */ | ||||
| void setBit (const int bitNumber) throw(); | |||||
| int toInteger() const throw(); | |||||
| //============================================================================== | |||||
| /** Resets the value to 0. */ | |||||
| void clear(); | |||||
| /** Clears a particular bit in the number. */ | |||||
| void clearBit (int bitNumber) throw(); | |||||
| /** Sets a specified bit to 1. */ | |||||
| void setBit (int bitNumber); | |||||
| /** Sets or clears a specified bit. */ | /** Sets or clears a specified bit. */ | ||||
| void setBit (const int bitNumber, | |||||
| const bool shouldBeSet) throw(); | |||||
| void setBit (int bitNumber, bool shouldBeSet); | |||||
| /** Sets a range of bits to be either on or off. | /** Sets a range of bits to be either on or off. | ||||
| @@ -105,32 +117,19 @@ public: | |||||
| @param numBits the number of bits to change | @param numBits the number of bits to change | ||||
| @param shouldBeSet whether to turn these bits on or off | @param shouldBeSet whether to turn these bits on or off | ||||
| */ | */ | ||||
| void setRange (int startBit, | |||||
| int numBits, | |||||
| const bool shouldBeSet) throw(); | |||||
| void setRange (int startBit, int numBits, bool shouldBeSet); | |||||
| /** Inserts a bit an a given position, shifting up any bits above it. */ | /** Inserts a bit an a given position, shifting up any bits above it. */ | ||||
| void insertBit (const int bitNumber, | |||||
| const bool shouldBeSet) throw(); | |||||
| /** Returns the value of a specified bit in the array. | |||||
| void insertBit (int bitNumber, bool shouldBeSet); | |||||
| If the index is out-of-range, the result will be false. | |||||
| */ | |||||
| bool operator[] (const int bit) const throw(); | |||||
| /** Returns true if no bits are set. */ | |||||
| bool isEmpty() const throw(); | |||||
| //============================================================================== | |||||
| /** Returns a range of bits in the array as a new BitArray. | |||||
| /** Returns a range of bits as a new BigInteger. | |||||
| e.g. getBitRangeAsInt (0, 64) would return the lowest 64 bits. | e.g. getBitRangeAsInt (0, 64) would return the lowest 64 bits. | ||||
| @see getBitRangeAsInt | @see getBitRangeAsInt | ||||
| */ | */ | ||||
| const BitArray getBitRange (int startBit, int numBits) const throw(); | |||||
| const BigInteger getBitRange (int startBit, int numBits) const; | |||||
| /** Returns a range of bits in the array as an integer value. | |||||
| /** Returns a range of bits as an integer value. | |||||
| e.g. getBitRangeAsInt (0, 32) would return the lowest 32 bits. | e.g. getBitRangeAsInt (0, 32) would return the lowest 32 bits. | ||||
| @@ -139,206 +138,191 @@ public: | |||||
| */ | */ | ||||
| int getBitRangeAsInt (int startBit, int numBits) const throw(); | int getBitRangeAsInt (int startBit, int numBits) const throw(); | ||||
| /** Sets a range of bits in the array based on an integer value. | |||||
| /** Sets a range of bits to an integer value. | |||||
| Copies the given integer into the array, starting at startBit, | |||||
| and only using up to numBits of the available bits. | |||||
| Copies the given integer onto a range of bits, starting at startBit, | |||||
| and using up to numBits of the available bits. | |||||
| */ | */ | ||||
| void setBitRangeAsInt (int startBit, int numBits, | |||||
| unsigned int valueToSet) throw(); | |||||
| void setBitRangeAsInt (int startBit, int numBits, unsigned int valueToSet); | |||||
| //============================================================================== | |||||
| /** Performs a bitwise OR with another BitArray. | |||||
| /** Shifts a section of bits left or right. | |||||
| The result ends up in this array. | |||||
| @param howManyBitsLeft how far to move the bits (+ve numbers shift it left, -ve numbers shift it right). | |||||
| @param startBit the first bit to affect - if this is > 0, only bits above that index will be affected. | |||||
| */ | */ | ||||
| void orWith (const BitArray& other) throw(); | |||||
| void shiftBits (int howManyBitsLeft, int startBit); | |||||
| /** Performs a bitwise AND with another BitArray. | |||||
| /** Returns the total number of set bits in the value. */ | |||||
| int countNumberOfSetBits() const throw(); | |||||
| The result ends up in this array. | |||||
| /** Looks for the index of the next set bit after a given starting point. | |||||
| This searches from startIndex (inclusive) upwards for the first set bit, | |||||
| and returns its index. If no set bits are found, it returns -1. | |||||
| */ | */ | ||||
| void andWith (const BitArray& other) throw(); | |||||
| int findNextSetBit (int startIndex = 0) const throw(); | |||||
| /** Performs a bitwise XOR with another BitArray. | |||||
| /** Looks for the index of the next clear bit after a given starting point. | |||||
| The result ends up in this array. | |||||
| This searches from startIndex (inclusive) upwards for the first clear bit, | |||||
| and returns its index. | |||||
| */ | */ | ||||
| void xorWith (const BitArray& other) throw(); | |||||
| /** Adds another BitArray's value to this one. | |||||
| int findNextClearBit (int startIndex = 0) const throw(); | |||||
| Treating the two arrays as large positive integers, this | |||||
| adds them up and puts the result in this array. | |||||
| /** Returns the index of the highest set bit in the number. | |||||
| If the value is zero, this will return -1. | |||||
| */ | */ | ||||
| void add (const BitArray& other) throw(); | |||||
| int getHighestBit() const throw(); | |||||
| /** Subtracts another BitArray's value from this one. | |||||
| //============================================================================== | |||||
| // All the standard arithmetic ops... | |||||
| BigInteger& operator+= (const BigInteger& other); | |||||
| BigInteger& operator-= (const BigInteger& other); | |||||
| BigInteger& operator*= (const BigInteger& other); | |||||
| BigInteger& operator/= (const BigInteger& other); | |||||
| BigInteger& operator|= (const BigInteger& other); | |||||
| BigInteger& operator&= (const BigInteger& other); | |||||
| BigInteger& operator^= (const BigInteger& other); | |||||
| BigInteger& operator%= (const BigInteger& other); | |||||
| BigInteger& operator<<= (int numBitsToShift); | |||||
| BigInteger& operator>>= (int numBitsToShift); | |||||
| BigInteger& operator++(); | |||||
| BigInteger& operator--(); | |||||
| const BigInteger operator++ (int); | |||||
| const BigInteger operator-- (int); | |||||
| const BigInteger operator-() const; | |||||
| const BigInteger operator+ (const BigInteger& other) const; | |||||
| const BigInteger operator- (const BigInteger& other) const; | |||||
| const BigInteger operator* (const BigInteger& other) const; | |||||
| const BigInteger operator/ (const BigInteger& other) const; | |||||
| const BigInteger operator| (const BigInteger& other) const; | |||||
| const BigInteger operator& (const BigInteger& other) const; | |||||
| const BigInteger operator^ (const BigInteger& other) const; | |||||
| const BigInteger operator% (const BigInteger& other) const; | |||||
| const BigInteger operator<< (int numBitsToShift) const; | |||||
| const BigInteger operator>> (int numBitsToShift) const; | |||||
| bool operator== (const BigInteger& other) const throw(); | |||||
| bool operator!= (const BigInteger& other) const throw(); | |||||
| bool operator< (const BigInteger& other) const throw(); | |||||
| bool operator<= (const BigInteger& other) const throw(); | |||||
| bool operator> (const BigInteger& other) const throw(); | |||||
| bool operator>= (const BigInteger& other) const throw(); | |||||
| Treating the two arrays as large positive integers, this | |||||
| subtracts them and puts the result in this array. | |||||
| //============================================================================== | |||||
| /** Does a signed comparison of two BigIntegers. | |||||
| Note that if the result should be negative, this won't be | |||||
| handled correctly. | |||||
| Return values are: | |||||
| - 0 if the numbers are the same | |||||
| - < 0 if this number is smaller than the other | |||||
| - > 0 if this number is bigger than the other | |||||
| */ | */ | ||||
| void subtract (const BitArray& other) throw(); | |||||
| int compare (const BigInteger& other) const throw(); | |||||
| /** Multiplies another BitArray's value with this one. | |||||
| /** Compares the magnitudes of two BigIntegers, ignoring their signs. | |||||
| Treating the two arrays as large positive integers, this | |||||
| multiplies them and puts the result in this array. | |||||
| Return values are: | |||||
| - 0 if the numbers are the same | |||||
| - < 0 if this number is smaller than the other | |||||
| - > 0 if this number is bigger than the other | |||||
| */ | */ | ||||
| void multiplyBy (const BitArray& other) throw(); | |||||
| int compareAbsolute (const BigInteger& other) const throw(); | |||||
| /** Divides another BitArray's value into this one and also produces a remainder. | |||||
| /** Divides this value by another one and returns the remainder. | |||||
| Treating the two arrays as large positive integers, this | |||||
| divides this value by the other, leaving the quotient in this | |||||
| array, and the remainder is copied into the other BitArray passed in. | |||||
| This number is divided by other, leaving the quotient in this number, | |||||
| with the remainder being copied to the other BigInteger passed in. | |||||
| */ | */ | ||||
| void divideBy (const BitArray& divisor, BitArray& remainder) throw(); | |||||
| /** Returns the largest value that will divide both this value and the one | |||||
| passed-in. | |||||
| */ | |||||
| const BitArray findGreatestCommonDivisor (BitArray other) const throw(); | |||||
| /** Performs a modulo operation on this value. | |||||
| void divideBy (const BigInteger& divisor, BigInteger& remainder); | |||||
| The result is stored in this value. | |||||
| /** Returns the largest value that will divide both this value and the one passed-in. | |||||
| */ | */ | ||||
| void modulo (const BitArray& divisor) throw(); | |||||
| const BigInteger findGreatestCommonDivisor (BigInteger other) const; | |||||
| /** Performs a combined exponent and modulo operation. | /** Performs a combined exponent and modulo operation. | ||||
| This BitArray's value becomes (this ^ exponent) % modulus. | |||||
| This BigInteger's value becomes (this ^ exponent) % modulus. | |||||
| */ | */ | ||||
| void exponentModulo (const BitArray& exponent, const BitArray& modulus) throw(); | |||||
| void exponentModulo (const BigInteger& exponent, const BigInteger& modulus); | |||||
| /** Performs an inverse modulo on the value. | /** Performs an inverse modulo on the value. | ||||
| i.e. the result is (this ^ -1) mod (modulus). | i.e. the result is (this ^ -1) mod (modulus). | ||||
| */ | */ | ||||
| void inverseModulo (const BitArray& modulus) throw(); | |||||
| /** Shifts a section of bits left or right. | |||||
| @param howManyBitsLeft how far to move the bits (+ve numbers shift it left, -ve numbers shift it right). | |||||
| @param startBit the first bit to affect - if this is > 0, only bits above that index will be affected. | |||||
| */ | |||||
| void shiftBits (int howManyBitsLeft, | |||||
| int startBit = 0) throw(); | |||||
| /** Does a signed comparison of two BitArrays. | |||||
| Return values are: | |||||
| - 0 if the numbers are the same | |||||
| - < 0 if this number is smaller than the other | |||||
| - > 0 if this number is bigger than the other | |||||
| */ | |||||
| int compare (const BitArray& other) const throw(); | |||||
| /** Compares the magnitudes of two BitArrays, ignoring their signs. | |||||
| Return values are: | |||||
| - 0 if the numbers are the same | |||||
| - < 0 if this number is smaller than the other | |||||
| - > 0 if this number is bigger than the other | |||||
| */ | |||||
| int compareAbsolute (const BitArray& other) const throw(); | |||||
| void inverseModulo (const BigInteger& modulus); | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Returns true if the value is less than zero. | /** Returns true if the value is less than zero. | ||||
| @see setNegative, negate | @see setNegative, negate | ||||
| */ | */ | ||||
| bool isNegative() const throw(); | bool isNegative() const throw(); | ||||
| /** Changes the sign of the number to be positive or negative. | /** Changes the sign of the number to be positive or negative. | ||||
| @see isNegative, negate | @see isNegative, negate | ||||
| */ | */ | ||||
| void setNegative (const bool shouldBeNegative) throw(); | void setNegative (const bool shouldBeNegative) throw(); | ||||
| /** Inverts the sign of the number. | /** Inverts the sign of the number. | ||||
| @see isNegative, setNegative | @see isNegative, setNegative | ||||
| */ | */ | ||||
| void negate() throw(); | void negate() throw(); | ||||
| //============================================================================== | //============================================================================== | ||||
| /** Counts the total number of set bits in the array. */ | |||||
| int countNumberOfSetBits() const throw(); | |||||
| /** Looks for the index of the next set bit after a given starting point. | |||||
| searches from startIndex (inclusive) upwards for the first set bit, | |||||
| and returns its index. | |||||
| If no set bits are found, it returns -1. | |||||
| */ | |||||
| int findNextSetBit (int startIndex = 0) const throw(); | |||||
| /** Looks for the index of the next clear bit after a given starting point. | |||||
| searches from startIndex (inclusive) upwards for the first clear bit, | |||||
| and returns its index. | |||||
| */ | |||||
| int findNextClearBit (int startIndex = 0) const throw(); | |||||
| /** Returns the index of the highest set bit in the array. | |||||
| If the array is empty, this will return -1. | |||||
| */ | |||||
| int getHighestBit() const throw(); | |||||
| //============================================================================== | |||||
| /** Converts the array to a number string. | |||||
| /** Converts the number to a string. | |||||
| Specify a base such as 2 (binary), 8 (octal), 10 (decimal), 16 (hex). | Specify a base such as 2 (binary), 8 (octal), 10 (decimal), 16 (hex). | ||||
| If minuimumNumCharacters is greater than 0, the returned string will be | |||||
| If minimumNumCharacters is greater than 0, the returned string will be | |||||
| padded with leading zeros to reach at least that length. | padded with leading zeros to reach at least that length. | ||||
| */ | */ | ||||
| const String toString (const int base, const int minimumNumCharacters = 1) const throw(); | |||||
| /** Converts a number string to an array. | |||||
| const String toString (int base, int minimumNumCharacters = 1) const; | |||||
| Any non-valid characters will be ignored. | |||||
| /** Reads the numeric value from a string. | |||||
| Specify a base such as 2 (binary), 8 (octal), 10 (decimal), 16 (hex). | Specify a base such as 2 (binary), 8 (octal), 10 (decimal), 16 (hex). | ||||
| Any invalid characters will be ignored. | |||||
| */ | */ | ||||
| void parseString (const String& text, | |||||
| const int base) throw(); | |||||
| void parseString (const String& text, int base); | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Turns the array into a block of binary data. | |||||
| /** Turns the number into a block of binary data. | |||||
| The data is arranged as little-endian, so the first byte of data is the low 8 bits | The data is arranged as little-endian, so the first byte of data is the low 8 bits | ||||
| of the array, and so on. | |||||
| of the number, and so on. | |||||
| @see loadFromMemoryBlock | @see loadFromMemoryBlock | ||||
| */ | */ | ||||
| const MemoryBlock toMemoryBlock() const throw(); | |||||
| const MemoryBlock toMemoryBlock() const; | |||||
| /** Copies a block of raw data onto this array. | |||||
| /** Converts a block of raw data into a number. | |||||
| The data is arranged as little-endian, so the first byte of data is the low 8 bits | The data is arranged as little-endian, so the first byte of data is the low 8 bits | ||||
| of the array, and so on. | |||||
| of the number, and so on. | |||||
| @see toMemoryBlock | @see toMemoryBlock | ||||
| */ | */ | ||||
| void loadFromMemoryBlock (const MemoryBlock& data) throw(); | |||||
| void loadFromMemoryBlock (const MemoryBlock& data); | |||||
| //============================================================================== | //============================================================================== | ||||
| juce_UseDebuggingNewOperator | juce_UseDebuggingNewOperator | ||||
| private: | private: | ||||
| void ensureSize (const int numVals) throw(); | |||||
| HeapBlock <unsigned int> values; | HeapBlock <unsigned int> values; | ||||
| int numValues, highestBit; | int numValues, highestBit; | ||||
| bool negative; | bool negative; | ||||
| void ensureSize (int numVals); | |||||
| static const BigInteger simpleGCD (BigInteger* m, BigInteger* n); | |||||
| }; | }; | ||||
| /** Writes a BigInteger to an OutputStream as a UTF8 decimal string. */ | |||||
| OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const BigInteger& value); | |||||
| //============================================================================== | |||||
| /** For backwards compatibility, BitArray is defined to be an alias for BigInteger. | |||||
| */ | |||||
| typedef BigInteger BitArray; | |||||
| #endif // __JUCE_BITARRAY_JUCEHEADER__ | #endif // __JUCE_BITARRAY_JUCEHEADER__ | ||||
| @@ -165,7 +165,7 @@ public: | |||||
| while (e != end) | while (e != end) | ||||
| { | { | ||||
| if (objectToLookFor == *e) | if (objectToLookFor == *e) | ||||
| return (int) (e - data.elements.getData()); | |||||
| return static_cast <int> (e - data.elements.getData()); | |||||
| ++e; | ++e; | ||||
| } | } | ||||
| @@ -466,7 +466,7 @@ public: | |||||
| { | { | ||||
| if (objectToRemove == *e) | if (objectToRemove == *e) | ||||
| { | { | ||||
| remove ((int) (e - data.elements.getData()), deleteObject); | |||||
| remove (static_cast <int> (e - data.elements.getData()), deleteObject); | |||||
| break; | break; | ||||
| } | } | ||||
| @@ -184,7 +184,7 @@ public: | |||||
| while (e != end) | while (e != end) | ||||
| { | { | ||||
| if (objectToLookFor == *e) | if (objectToLookFor == *e) | ||||
| return (int) (e - data.elements.getData()); | |||||
| return static_cast <int> (e - data.elements.getData()); | |||||
| ++e; | ++e; | ||||
| } | } | ||||
| @@ -34,9 +34,9 @@ | |||||
| /** | /** | ||||
| Holds a set of primitive values, storing them as a set of ranges. | Holds a set of primitive values, storing them as a set of ranges. | ||||
| This container acts like a simple BitArray, but can efficiently hold large | |||||
| continguous ranges of values. It's quite a specialised class, mostly useful | |||||
| for things like keeping the set of selected rows in a listbox. | |||||
| This container acts like an array, but can efficiently hold large continguous | |||||
| ranges of values. It's quite a specialised class, mostly useful for things | |||||
| like keeping the set of selected rows in a listbox. | |||||
| The type used as a template paramter must be an integer type, such as int, short, | The type used as a template paramter must be an integer type, such as int, short, | ||||
| int64, etc. | int64, etc. | ||||
| @@ -94,20 +94,20 @@ double Random::nextDouble() throw() | |||||
| return static_cast <uint32> (nextInt()) / (double) 0xffffffff; | return static_cast <uint32> (nextInt()) / (double) 0xffffffff; | ||||
| } | } | ||||
| const BitArray Random::nextLargeNumber (const BitArray& maximumValue) throw() | |||||
| const BigInteger Random::nextLargeNumber (const BigInteger& maximumValue) | |||||
| { | { | ||||
| BitArray n; | |||||
| BigInteger n; | |||||
| do | do | ||||
| { | { | ||||
| fillBitsRandomly (n, 0, maximumValue.getHighestBit() + 1); | fillBitsRandomly (n, 0, maximumValue.getHighestBit() + 1); | ||||
| } | } | ||||
| while (n.compare (maximumValue) >= 0); | |||||
| while (n >= maximumValue); | |||||
| return n; | return n; | ||||
| } | } | ||||
| void Random::fillBitsRandomly (BitArray& arrayToChange, int startBit, int numBits) throw() | |||||
| void Random::fillBitsRandomly (BigInteger& arrayToChange, int startBit, int numBits) | |||||
| { | { | ||||
| arrayToChange.setBit (startBit + numBits - 1, true); // to force the array to pre-allocate space | arrayToChange.setBit (startBit + numBits - 1, true); // to force the array to pre-allocate space | ||||
| @@ -84,14 +84,14 @@ public: | |||||
| */ | */ | ||||
| bool nextBool() throw(); | bool nextBool() throw(); | ||||
| /** Returns a BitArray containing a random number. | |||||
| /** Returns a BigInteger containing a random number. | |||||
| @returns a random value in the range 0 to (maximumValue - 1). | @returns a random value in the range 0 to (maximumValue - 1). | ||||
| */ | */ | ||||
| const BitArray nextLargeNumber (const BitArray& maximumValue) throw(); | |||||
| const BigInteger nextLargeNumber (const BigInteger& maximumValue); | |||||
| /** Sets a range of bits in a BitArray to random values. */ | |||||
| void fillBitsRandomly (BitArray& arrayToChange, int startBit, int numBits) throw(); | |||||
| /** Sets a range of bits in a BigInteger to random values. */ | |||||
| void fillBitsRandomly (BigInteger& arrayToChange, int startBit, int numBits); | |||||
| //============================================================================== | //============================================================================== | ||||
| /** To avoid the overhead of having to create a new Random object whenever | /** To avoid the overhead of having to create a new Random object whenever | ||||
| @@ -33,7 +33,7 @@ | |||||
| */ | */ | ||||
| #define JUCE_MAJOR_VERSION 1 | #define JUCE_MAJOR_VERSION 1 | ||||
| #define JUCE_MINOR_VERSION 51 | #define JUCE_MINOR_VERSION 51 | ||||
| #define JUCE_BUILDNUMBER 10 | |||||
| #define JUCE_BUILDNUMBER 11 | |||||
| /** Current Juce version number. | /** Current Juce version number. | ||||
| @@ -35,7 +35,7 @@ BEGIN_JUCE_NAMESPACE | |||||
| //============================================================================== | //============================================================================== | ||||
| namespace PrimesHelpers | namespace PrimesHelpers | ||||
| { | { | ||||
| static void createSmallSieve (const int numBits, BitArray& result) throw() | |||||
| static void createSmallSieve (const int numBits, BigInteger& result) | |||||
| { | { | ||||
| result.setBit (numBits); | result.setBit (numBits); | ||||
| result.clearBit (numBits); // to enlarge the array | result.clearBit (numBits); // to enlarge the array | ||||
| @@ -53,11 +53,8 @@ namespace PrimesHelpers | |||||
| while (n <= (numBits >> 1)); | while (n <= (numBits >> 1)); | ||||
| } | } | ||||
| static void bigSieve (const BitArray& base, | |||||
| const int numBits, | |||||
| BitArray& result, | |||||
| const BitArray& smallSieve, | |||||
| const int smallSieveSize) throw() | |||||
| static void bigSieve (const BigInteger& base, const int numBits, BigInteger& result, | |||||
| const BigInteger& smallSieve, const int smallSieveSize) | |||||
| { | { | ||||
| jassert (! base[0]); // must be even! | jassert (! base[0]); // must be even! | ||||
| @@ -70,13 +67,12 @@ namespace PrimesHelpers | |||||
| { | { | ||||
| const int prime = (index << 1) + 1; | const int prime = (index << 1) + 1; | ||||
| BitArray r (base); | |||||
| BitArray remainder; | |||||
| BigInteger r (base), remainder; | |||||
| r.divideBy (prime, remainder); | r.divideBy (prime, remainder); | ||||
| int i = prime - remainder.getBitRangeAsInt (0, 32); | int i = prime - remainder.getBitRangeAsInt (0, 32); | ||||
| if (r.isEmpty()) | |||||
| if (r.isZero()) | |||||
| i += prime; | i += prime; | ||||
| if ((i & 1) == 0) | if ((i & 1) == 0) | ||||
| @@ -95,18 +91,14 @@ namespace PrimesHelpers | |||||
| while (index < smallSieveSize); | while (index < smallSieveSize); | ||||
| } | } | ||||
| static bool findCandidate (const BitArray& base, | |||||
| const BitArray& sieve, | |||||
| const int numBits, | |||||
| BitArray& result, | |||||
| const int certainty) throw() | |||||
| static bool findCandidate (const BigInteger& base, const BigInteger& sieve, | |||||
| const int numBits, BigInteger& result, const int certainty) | |||||
| { | { | ||||
| for (int i = 0; i < numBits; ++i) | for (int i = 0; i < numBits; ++i) | ||||
| { | { | ||||
| if (! sieve[i]) | if (! sieve[i]) | ||||
| { | { | ||||
| result = base; | |||||
| result.add (BitArray ((unsigned int) ((i << 1) + 1))); | |||||
| result = base + (unsigned int) ((i << 1) + 1); | |||||
| if (Primes::isProbablyPrime (result, certainty)) | if (Primes::isProbablyPrime (result, certainty)) | ||||
| return true; | return true; | ||||
| @@ -115,13 +107,63 @@ namespace PrimesHelpers | |||||
| return false; | return false; | ||||
| } | } | ||||
| static bool passesMillerRabin (const BigInteger& n, int iterations) | |||||
| { | |||||
| const BigInteger one (1), two (2); | |||||
| const BigInteger nMinusOne (n - one); | |||||
| BigInteger d (nMinusOne); | |||||
| const int s = d.findNextSetBit (0); | |||||
| d >>= s; | |||||
| BigInteger smallPrimes; | |||||
| int numBitsInSmallPrimes = 0; | |||||
| for (;;) | |||||
| { | |||||
| numBitsInSmallPrimes += 256; | |||||
| createSmallSieve (numBitsInSmallPrimes, smallPrimes); | |||||
| const int numPrimesFound = numBitsInSmallPrimes - smallPrimes.countNumberOfSetBits(); | |||||
| if (numPrimesFound > iterations + 1) | |||||
| break; | |||||
| } | |||||
| int smallPrime = 2; | |||||
| while (--iterations >= 0) | |||||
| { | |||||
| smallPrime = smallPrimes.findNextClearBit (smallPrime + 1); | |||||
| BigInteger r (smallPrime); | |||||
| r.exponentModulo (d, n); | |||||
| if (r != one && r != nMinusOne) | |||||
| { | |||||
| for (int j = 0; j < s; ++j) | |||||
| { | |||||
| r.exponentModulo (two, n); | |||||
| if (r == nMinusOne) | |||||
| break; | |||||
| } | |||||
| if (r != nMinusOne) | |||||
| return false; | |||||
| } | |||||
| } | |||||
| return true; | |||||
| } | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| const BitArray Primes::createProbablePrime (const int bitLength, | |||||
| const int certainty, | |||||
| const int* randomSeeds, | |||||
| int numRandomSeeds) throw() | |||||
| const BigInteger Primes::createProbablePrime (const int bitLength, | |||||
| const int certainty, | |||||
| const int* randomSeeds, | |||||
| int numRandomSeeds) | |||||
| { | { | ||||
| using namespace PrimesHelpers; | using namespace PrimesHelpers; | ||||
| int defaultSeeds [16]; | int defaultSeeds [16]; | ||||
| @@ -141,20 +183,20 @@ const BitArray Primes::createProbablePrime (const int bitLength, | |||||
| } | } | ||||
| } | } | ||||
| BitArray smallSieve; | |||||
| BigInteger smallSieve; | |||||
| const int smallSieveSize = 15000; | const int smallSieveSize = 15000; | ||||
| createSmallSieve (smallSieveSize, smallSieve); | createSmallSieve (smallSieveSize, smallSieve); | ||||
| BitArray p; | |||||
| BigInteger p; | |||||
| for (int i = numRandomSeeds; --i >= 0;) | for (int i = numRandomSeeds; --i >= 0;) | ||||
| { | { | ||||
| BitArray p2; | |||||
| BigInteger p2; | |||||
| Random r (randomSeeds[i]); | Random r (randomSeeds[i]); | ||||
| r.fillBitsRandomly (p2, 0, bitLength); | r.fillBitsRandomly (p2, 0, bitLength); | ||||
| p.xorWith (p2); | |||||
| p ^= p2; | |||||
| } | } | ||||
| p.setBit (bitLength - 1); | p.setBit (bitLength - 1); | ||||
| @@ -164,81 +206,26 @@ const BitArray Primes::createProbablePrime (const int bitLength, | |||||
| while (p.getHighestBit() < bitLength) | while (p.getHighestBit() < bitLength) | ||||
| { | { | ||||
| p.add (2 * searchLen); | |||||
| p += 2 * searchLen; | |||||
| BitArray sieve; | |||||
| BigInteger sieve; | |||||
| bigSieve (p, searchLen, sieve, | bigSieve (p, searchLen, sieve, | ||||
| smallSieve, smallSieveSize); | smallSieve, smallSieveSize); | ||||
| BitArray candidate; | |||||
| BigInteger candidate; | |||||
| if (findCandidate (p, sieve, searchLen, candidate, certainty)) | if (findCandidate (p, sieve, searchLen, candidate, certainty)) | ||||
| return candidate; | return candidate; | ||||
| } | } | ||||
| jassertfalse | jassertfalse | ||||
| return BitArray(); | |||||
| return BigInteger(); | |||||
| } | } | ||||
| static bool passesMillerRabin (const BitArray& n, int iterations) throw() | |||||
| bool Primes::isProbablyPrime (const BigInteger& number, const int certainty) | |||||
| { | { | ||||
| using namespace PrimesHelpers; | using namespace PrimesHelpers; | ||||
| const BitArray one (1); | |||||
| const BitArray two (2); | |||||
| BitArray nMinusOne (n); | |||||
| nMinusOne.subtract (one); | |||||
| BitArray d (nMinusOne); | |||||
| const int s = d.findNextSetBit (0); | |||||
| d.shiftBits (-s); | |||||
| BitArray smallPrimes; | |||||
| int numBitsInSmallPrimes = 0; | |||||
| for (;;) | |||||
| { | |||||
| numBitsInSmallPrimes += 256; | |||||
| createSmallSieve (numBitsInSmallPrimes, smallPrimes); | |||||
| const int numPrimesFound = numBitsInSmallPrimes - smallPrimes.countNumberOfSetBits(); | |||||
| if (numPrimesFound > iterations + 1) | |||||
| break; | |||||
| } | |||||
| int smallPrime = 2; | |||||
| while (--iterations >= 0) | |||||
| { | |||||
| smallPrime = smallPrimes.findNextClearBit (smallPrime + 1); | |||||
| BitArray r (smallPrime); | |||||
| //r.createRandomNumber (nMinusOne); | |||||
| r.exponentModulo (d, n); | |||||
| if (! (r == one || r == nMinusOne)) | |||||
| { | |||||
| for (int j = 0; j < s; ++j) | |||||
| { | |||||
| r.exponentModulo (two, n); | |||||
| if (r == nMinusOne) | |||||
| break; | |||||
| } | |||||
| if (r != nMinusOne) | |||||
| return false; | |||||
| } | |||||
| } | |||||
| return true; | |||||
| } | |||||
| bool Primes::isProbablyPrime (const BitArray& number, | |||||
| const int certainty) throw() | |||||
| { | |||||
| if (! number[0]) | if (! number[0]) | ||||
| return false; | return false; | ||||
| @@ -254,9 +241,7 @@ bool Primes::isProbablyPrime (const BitArray& number, | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| const BitArray screen (2 * 3 * 5 * 7 * 11 * 13 * 17 * 19 * 23); | |||||
| if (number.findGreatestCommonDivisor (screen) != BitArray (1)) | |||||
| if (number.findGreatestCommonDivisor (2 * 3 * 5 * 7 * 11 * 13 * 17 * 19 * 23) != 1) | |||||
| return false; | return false; | ||||
| return passesMillerRabin (number, certainty); | return passesMillerRabin (number, certainty); | ||||
| @@ -35,7 +35,7 @@ | |||||
| This class contains static methods for generating and testing prime numbers. | This class contains static methods for generating and testing prime numbers. | ||||
| @see BitArray | |||||
| @see BigInteger | |||||
| */ | */ | ||||
| class JUCE_API Primes | class JUCE_API Primes | ||||
| { | { | ||||
| @@ -50,10 +50,10 @@ public: | |||||
| which to seed the random number generation, improving the security of the | which to seed the random number generation, improving the security of the | ||||
| keys generated. | keys generated. | ||||
| */ | */ | ||||
| static const BitArray createProbablePrime (int bitLength, | |||||
| int certainty, | |||||
| const int* randomSeeds = 0, | |||||
| int numRandomSeeds = 0) throw(); | |||||
| static const BigInteger createProbablePrime (int bitLength, | |||||
| int certainty, | |||||
| const int* randomSeeds = 0, | |||||
| int numRandomSeeds = 0); | |||||
| /** Tests a number to see if it's prime. | /** Tests a number to see if it's prime. | ||||
| @@ -63,8 +63,7 @@ public: | |||||
| The certainty parameter specifies how many iterations to use when testing - a | The certainty parameter specifies how many iterations to use when testing - a | ||||
| safe value might be anything over about 20-30. | safe value might be anything over about 20-30. | ||||
| */ | */ | ||||
| static bool isProbablyPrime (const BitArray& number, | |||||
| int certainty) throw(); | |||||
| static bool isProbablyPrime (const BigInteger& number, int certainty); | |||||
| }; | }; | ||||
| @@ -33,11 +33,11 @@ BEGIN_JUCE_NAMESPACE | |||||
| //============================================================================== | //============================================================================== | ||||
| RSAKey::RSAKey() throw() | |||||
| RSAKey::RSAKey() | |||||
| { | { | ||||
| } | } | ||||
| RSAKey::RSAKey (const String& s) throw() | |||||
| RSAKey::RSAKey (const String& s) | |||||
| { | { | ||||
| if (s.containsChar (T(','))) | if (s.containsChar (T(','))) | ||||
| { | { | ||||
| @@ -51,97 +51,75 @@ RSAKey::RSAKey (const String& s) throw() | |||||
| } | } | ||||
| } | } | ||||
| RSAKey::~RSAKey() throw() | |||||
| RSAKey::~RSAKey() | |||||
| { | { | ||||
| } | } | ||||
| const String RSAKey::toString() const throw() | |||||
| const String RSAKey::toString() const | |||||
| { | { | ||||
| return part1.toString (16) + T(",") + part2.toString (16); | |||||
| return part1.toString (16) + "," + part2.toString (16); | |||||
| } | } | ||||
| bool RSAKey::applyToValue (BitArray& value) const throw() | |||||
| bool RSAKey::applyToValue (BigInteger& value) const | |||||
| { | { | ||||
| if (part1.isEmpty() || part2.isEmpty() | |||||
| || value.compare (0) <= 0) | |||||
| if (part1.isZero() || part2.isZero() || value <= 0) | |||||
| { | { | ||||
| jassertfalse // using an uninitialised key | jassertfalse // using an uninitialised key | ||||
| value.clear(); | value.clear(); | ||||
| return false; | return false; | ||||
| } | } | ||||
| BitArray result; | |||||
| BigInteger result; | |||||
| while (! value.isEmpty()) | |||||
| while (! value.isZero()) | |||||
| { | { | ||||
| result.multiplyBy (part2); | |||||
| result *= part2; | |||||
| BitArray remainder; | |||||
| BigInteger remainder; | |||||
| value.divideBy (part2, remainder); | value.divideBy (part2, remainder); | ||||
| remainder.exponentModulo (part1, part2); | remainder.exponentModulo (part1, part2); | ||||
| result.add (remainder); | |||||
| result += remainder; | |||||
| } | } | ||||
| value = result; | |||||
| value.swapWith (result); | |||||
| return true; | return true; | ||||
| } | } | ||||
| static const BitArray findBestCommonDivisor (const BitArray& p, | |||||
| const BitArray& q) throw() | |||||
| static const BigInteger findBestCommonDivisor (const BigInteger& p, const BigInteger& q) | |||||
| { | { | ||||
| const BitArray one (1); | |||||
| // try 3, 5, 9, 17, etc first because these only contain 2 bits and so | // try 3, 5, 9, 17, etc first because these only contain 2 bits and so | ||||
| // are fast to divide + multiply | // are fast to divide + multiply | ||||
| for (int i = 2; i <= 65536; i *= 2) | for (int i = 2; i <= 65536; i *= 2) | ||||
| { | { | ||||
| const BitArray e (1 + i); | |||||
| const BigInteger e (1 + i); | |||||
| if (e.findGreatestCommonDivisor (p) == one | |||||
| && e.findGreatestCommonDivisor (q) == one) | |||||
| { | |||||
| if (e.findGreatestCommonDivisor (p).isOne() && e.findGreatestCommonDivisor (q).isOne()) | |||||
| return e; | return e; | ||||
| } | |||||
| } | } | ||||
| BitArray e (4); | |||||
| BigInteger e (4); | |||||
| while (! (e.findGreatestCommonDivisor (p) == one | |||||
| && e.findGreatestCommonDivisor (q) == one)) | |||||
| { | |||||
| e.add (one); | |||||
| } | |||||
| while (! (e.findGreatestCommonDivisor (p).isOne() && e.findGreatestCommonDivisor (q).isOne())) | |||||
| ++e; | |||||
| return e; | return e; | ||||
| } | } | ||||
| void RSAKey::createKeyPair (RSAKey& publicKey, | |||||
| RSAKey& privateKey, | |||||
| const int numBits, | |||||
| const int* randomSeeds, | |||||
| const int numRandomSeeds) throw() | |||||
| void RSAKey::createKeyPair (RSAKey& publicKey, RSAKey& privateKey, | |||||
| const int numBits, const int* randomSeeds, const int numRandomSeeds) | |||||
| { | { | ||||
| jassert (numBits > 16); // not much point using less than this.. | jassert (numBits > 16); // not much point using less than this.. | ||||
| BitArray p (Primes::createProbablePrime (numBits / 2, 30, randomSeeds, numRandomSeeds)); | |||||
| BitArray q (Primes::createProbablePrime (numBits - numBits / 2, 30, randomSeeds, numRandomSeeds)); | |||||
| BitArray n (p); | |||||
| n.multiplyBy (q); // n = pq | |||||
| const BitArray one (1); | |||||
| p.subtract (one); | |||||
| q.subtract (one); | |||||
| BitArray m (p); | |||||
| m.multiplyBy (q); // m = (p - 1)(q - 1) | |||||
| BigInteger p (Primes::createProbablePrime (numBits / 2, 30, randomSeeds, numRandomSeeds)); | |||||
| BigInteger q (Primes::createProbablePrime (numBits - numBits / 2, 30, randomSeeds, numRandomSeeds)); | |||||
| const BitArray e (findBestCommonDivisor (p, q)); | |||||
| const BigInteger n (p * q); | |||||
| const BigInteger m (--p * --q); | |||||
| const BigInteger e (findBestCommonDivisor (p, q)); | |||||
| BitArray d (e); | |||||
| BigInteger d (e); | |||||
| d.inverseModulo (m); | d.inverseModulo (m); | ||||
| publicKey.part1 = e; | publicKey.part1 = e; | ||||
| @@ -44,23 +44,23 @@ public: | |||||
| Initialise a pair of objects for use with the createKeyPair() method. | Initialise a pair of objects for use with the createKeyPair() method. | ||||
| */ | */ | ||||
| RSAKey() throw(); | |||||
| RSAKey(); | |||||
| /** Loads a key from an encoded string representation. | /** Loads a key from an encoded string representation. | ||||
| This reloads a key from a string created by the toString() method. | This reloads a key from a string created by the toString() method. | ||||
| */ | */ | ||||
| RSAKey (const String& stringRepresentation) throw(); | |||||
| RSAKey (const String& stringRepresentation); | |||||
| /** Destructor. */ | /** Destructor. */ | ||||
| ~RSAKey() throw(); | |||||
| ~RSAKey(); | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Turns the key into a string representation. | /** Turns the key into a string representation. | ||||
| This can be reloaded using the constructor that takes a string. | This can be reloaded using the constructor that takes a string. | ||||
| */ | */ | ||||
| const String toString() const throw(); | |||||
| const String toString() const; | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Encodes or decodes a value. | /** Encodes or decodes a value. | ||||
| @@ -76,7 +76,7 @@ public: | |||||
| happily do its job and return true, but the result won't be what you were expecting. | happily do its job and return true, but the result won't be what you were expecting. | ||||
| It's your responsibility to check that the result is what you wanted. | It's your responsibility to check that the result is what you wanted. | ||||
| */ | */ | ||||
| bool applyToValue (BitArray& value) const throw(); | |||||
| bool applyToValue (BigInteger& value) const; | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Creates a public/private key-pair. | /** Creates a public/private key-pair. | ||||
| @@ -93,16 +93,16 @@ public: | |||||
| */ | */ | ||||
| static void createKeyPair (RSAKey& publicKey, | static void createKeyPair (RSAKey& publicKey, | ||||
| RSAKey& privateKey, | RSAKey& privateKey, | ||||
| const int numBits, | |||||
| int numBits, | |||||
| const int* randomSeeds = 0, | const int* randomSeeds = 0, | ||||
| const int numRandomSeeds = 0) throw(); | |||||
| int numRandomSeeds = 0); | |||||
| //============================================================================== | //============================================================================== | ||||
| juce_UseDebuggingNewOperator | juce_UseDebuggingNewOperator | ||||
| protected: | protected: | ||||
| BitArray part1, part2; | |||||
| BigInteger part1, part2; | |||||
| }; | }; | ||||
| @@ -243,7 +243,7 @@ private: | |||||
| TableListBox& owner; | TableListBox& owner; | ||||
| int row; | int row; | ||||
| bool isSelected, isDragging, selectRowOnMouseUp; | bool isSelected, isDragging, selectRowOnMouseUp; | ||||
| BitArray columnsWithComponents; | |||||
| BigInteger columnsWithComponents; | |||||
| Component* findChildComponentForColumn (const int columnId) const | Component* findChildComponentForColumn (const int columnId) const | ||||
| { | { | ||||
| @@ -192,7 +192,7 @@ public: | |||||
| const int visibleTop = -getY(); | const int visibleTop = -getY(); | ||||
| const int visibleBottom = visibleTop + getParentHeight(); | const int visibleBottom = visibleTop + getParentHeight(); | ||||
| BitArray itemsToKeep; | |||||
| BigInteger itemsToKeep; | |||||
| TreeViewItem* item = owner->rootItem; | TreeViewItem* item = owner->rootItem; | ||||
| int y = (item != 0 && !owner->rootItemVisible) ? -item->itemHeight : 0; | int y = (item != 0 && !owner->rootItemVisible) ? -item->itemHeight : 0; | ||||
| @@ -101,7 +101,7 @@ FileBrowserComponent::FileBrowserComponent (int flags_, | |||||
| currentPathBox->setEditableText (true); | currentPathBox->setEditableText (true); | ||||
| StringArray rootNames, rootPaths; | StringArray rootNames, rootPaths; | ||||
| const BitArray separators (getRoots (rootNames, rootPaths)); | |||||
| const BigInteger separators (getRoots (rootNames, rootPaths)); | |||||
| for (int i = 0; i < rootNames.size(); ++i) | for (int i = 0; i < rootNames.size(); ++i) | ||||
| { | { | ||||
| @@ -457,9 +457,9 @@ void FileBrowserComponent::comboBoxChanged (ComboBox*) | |||||
| } | } | ||||
| } | } | ||||
| const BitArray FileBrowserComponent::getRoots (StringArray& rootNames, StringArray& rootPaths) | |||||
| const BigInteger FileBrowserComponent::getRoots (StringArray& rootNames, StringArray& rootPaths) | |||||
| { | { | ||||
| BitArray separators; | |||||
| BigInteger separators; | |||||
| #if JUCE_WINDOWS | #if JUCE_WINDOWS | ||||
| Array<File> roots; | Array<File> roots; | ||||
| @@ -203,7 +203,7 @@ public: | |||||
| juce_UseDebuggingNewOperator | juce_UseDebuggingNewOperator | ||||
| protected: | protected: | ||||
| virtual const BitArray getRoots (StringArray& rootNames, StringArray& rootPaths); | |||||
| virtual const BigInteger getRoots (StringArray& rootNames, StringArray& rootPaths); | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -856,9 +856,9 @@ public: | |||||
| if (setup.useStereoPairs) | if (setup.useStereoPairs) | ||||
| { | { | ||||
| BitArray bits; | |||||
| BitArray& original = (type == audioInputType ? config.inputChannels | |||||
| : config.outputChannels); | |||||
| BigInteger bits; | |||||
| BigInteger& original = (type == audioInputType ? config.inputChannels | |||||
| : config.outputChannels); | |||||
| int i; | int i; | ||||
| for (i = 0; i < 256; i += 2) | for (i = 0; i < 256; i += 2) | ||||
| @@ -901,7 +901,7 @@ public: | |||||
| } | } | ||||
| } | } | ||||
| static void flipBit (BitArray& chans, int index, int minNumber, int maxNumber) | |||||
| static void flipBit (BigInteger& chans, int index, int minNumber, int maxNumber) | |||||
| { | { | ||||
| const int numActive = chans.countNumberOfSetBits(); | const int numActive = chans.countNumberOfSetBits(); | ||||
| @@ -392,7 +392,7 @@ private: | |||||
| int midiChannel, midiInChannelMask; | int midiChannel, midiInChannelMask; | ||||
| float velocity; | float velocity; | ||||
| int noteUnderMouse, mouseDownNote; | int noteUnderMouse, mouseDownNote; | ||||
| BitArray keysPressed, keysCurrentlyDrawnDown; | |||||
| BigInteger keysPressed, keysCurrentlyDrawnDown; | |||||
| int rangeStart, rangeEnd, firstKey; | int rangeStart, rangeEnd, firstKey; | ||||
| bool canScroll, mouseDragging, useMousePositionForVelocity; | bool canScroll, mouseDragging, useMousePositionForVelocity; | ||||
| @@ -362,8 +362,8 @@ public: | |||||
| close(); | close(); | ||||
| } | } | ||||
| void open (BitArray inputChannels, | |||||
| BitArray outputChannels, | |||||
| void open (BigInteger inputChannels, | |||||
| BigInteger outputChannels, | |||||
| const double sampleRate_, | const double sampleRate_, | ||||
| const int bufferSize_) | const int bufferSize_) | ||||
| { | { | ||||
| @@ -581,7 +581,7 @@ public: | |||||
| String error; | String error; | ||||
| double sampleRate; | double sampleRate; | ||||
| int bufferSize; | int bufferSize; | ||||
| BitArray currentInputChans, currentOutputChans; | |||||
| BigInteger currentInputChans, currentOutputChans; | |||||
| Array <int> sampleRates; | Array <int> sampleRates; | ||||
| StringArray channelNamesOut, channelNamesIn; | StringArray channelNamesOut, channelNamesIn; | ||||
| @@ -704,8 +704,8 @@ public: | |||||
| return 512; | return 512; | ||||
| } | } | ||||
| const String open (const BitArray& inputChannels, | |||||
| const BitArray& outputChannels, | |||||
| const String open (const BigInteger& inputChannels, | |||||
| const BigInteger& outputChannels, | |||||
| double sampleRate, | double sampleRate, | ||||
| int bufferSizeSamples) | int bufferSizeSamples) | ||||
| { | { | ||||
| @@ -760,12 +760,12 @@ public: | |||||
| return internal->getBitDepth(); | return internal->getBitDepth(); | ||||
| } | } | ||||
| const BitArray getActiveOutputChannels() const | |||||
| const BigInteger getActiveOutputChannels() const | |||||
| { | { | ||||
| return internal->currentOutputChans; | return internal->currentOutputChans; | ||||
| } | } | ||||
| const BitArray getActiveInputChannels() const | |||||
| const BigInteger getActiveInputChannels() const | |||||
| { | { | ||||
| return internal->currentInputChans; | return internal->currentInputChans; | ||||
| } | } | ||||
| @@ -211,7 +211,7 @@ public: | |||||
| int getBufferSizeSamples (int index) { return getDefaultBufferSize(); } | int getBufferSizeSamples (int index) { return getDefaultBufferSize(); } | ||||
| int getDefaultBufferSize() { return client != 0 ? JUCE_NAMESPACE::jack_get_buffer_size (client) : 0; } | int getDefaultBufferSize() { return client != 0 ? JUCE_NAMESPACE::jack_get_buffer_size (client) : 0; } | ||||
| const String open (const BitArray& inputChannels, const BitArray& outputChannels, | |||||
| const String open (const BigInteger& inputChannels, const BigInteger& outputChannels, | |||||
| double sampleRate, int bufferSizeSamples) | double sampleRate, int bufferSizeSamples) | ||||
| { | { | ||||
| if (client == 0) | if (client == 0) | ||||
| @@ -228,13 +228,13 @@ public: | |||||
| JUCE_NAMESPACE::jack_activate (client); | JUCE_NAMESPACE::jack_activate (client); | ||||
| isOpen_ = true; | isOpen_ = true; | ||||
| if (! inputChannels.isEmpty()) | |||||
| if (! inputChannels.isZero()) | |||||
| { | { | ||||
| const char** const ports = JUCE_NAMESPACE::jack_get_ports (client, 0, 0, /* JackPortIsPhysical | */ JackPortIsOutput); | const char** const ports = JUCE_NAMESPACE::jack_get_ports (client, 0, 0, /* JackPortIsPhysical | */ JackPortIsOutput); | ||||
| if (ports != 0) | if (ports != 0) | ||||
| { | { | ||||
| const int numInputChannels = inputChannels.getHighestBit () + 1; | |||||
| const int numInputChannels = inputChannels.getHighestBit() + 1; | |||||
| for (int i = 0; i < numInputChannels; ++i) | for (int i = 0; i < numInputChannels; ++i) | ||||
| { | { | ||||
| @@ -252,13 +252,13 @@ public: | |||||
| } | } | ||||
| } | } | ||||
| if (! outputChannels.isEmpty()) | |||||
| if (! outputChannels.isZero()) | |||||
| { | { | ||||
| const char** const ports = JUCE_NAMESPACE::jack_get_ports (client, 0, 0, /* JackPortIsPhysical | */ JackPortIsInput); | const char** const ports = JUCE_NAMESPACE::jack_get_ports (client, 0, 0, /* JackPortIsPhysical | */ JackPortIsInput); | ||||
| if (ports != 0) | if (ports != 0) | ||||
| { | { | ||||
| const int numOutputChannels = outputChannels.getHighestBit () + 1; | |||||
| const int numOutputChannels = outputChannels.getHighestBit() + 1; | |||||
| for (int i = 0; i < numOutputChannels; ++i) | for (int i = 0; i < numOutputChannels; ++i) | ||||
| { | { | ||||
| @@ -324,9 +324,9 @@ public: | |||||
| int getCurrentBitDepth() { return 32; } | int getCurrentBitDepth() { return 32; } | ||||
| const String getLastError() { return lastError; } | const String getLastError() { return lastError; } | ||||
| const BitArray getActiveOutputChannels() const | |||||
| const BigInteger getActiveOutputChannels() const | |||||
| { | { | ||||
| BitArray outputBits; | |||||
| BigInteger outputBits; | |||||
| for (int i = 0; i < outputPorts.size(); i++) | for (int i = 0; i < outputPorts.size(); i++) | ||||
| if (JUCE_NAMESPACE::jack_port_connected ((jack_port_t*) outputPorts [i])) | if (JUCE_NAMESPACE::jack_port_connected ((jack_port_t*) outputPorts [i])) | ||||
| @@ -335,9 +335,9 @@ public: | |||||
| return outputBits; | return outputBits; | ||||
| } | } | ||||
| const BitArray getActiveInputChannels() const | |||||
| const BigInteger getActiveInputChannels() const | |||||
| { | { | ||||
| BitArray inputBits; | |||||
| BigInteger inputBits; | |||||
| for (int i = 0; i < inputPorts.size(); i++) | for (int i = 0; i < inputPorts.size(); i++) | ||||
| if (JUCE_NAMESPACE::jack_port_connected ((jack_port_t*) inputPorts [i])) | if (JUCE_NAMESPACE::jack_port_connected ((jack_port_t*) inputPorts [i])) | ||||
| @@ -98,8 +98,8 @@ public: | |||||
| return 1024; | return 1024; | ||||
| } | } | ||||
| const String open (const BitArray& inputChannels, | |||||
| const BitArray& outputChannels, | |||||
| const String open (const BigInteger& inputChannels, | |||||
| const BigInteger& outputChannels, | |||||
| double sampleRate, | double sampleRate, | ||||
| int bufferSize) | int bufferSize) | ||||
| { | { | ||||
| @@ -178,12 +178,12 @@ public: | |||||
| return 16; | return 16; | ||||
| } | } | ||||
| const BitArray getActiveOutputChannels() const | |||||
| const BigInteger getActiveOutputChannels() const | |||||
| { | { | ||||
| return activeOutputChans; | return activeOutputChans; | ||||
| } | } | ||||
| const BitArray getActiveInputChannels() const | |||||
| const BigInteger getActiveInputChannels() const | |||||
| { | { | ||||
| return activeInputChans; | return activeInputChans; | ||||
| } | } | ||||
| @@ -251,7 +251,7 @@ private: | |||||
| AudioUnit audioUnit; | AudioUnit audioUnit; | ||||
| UInt32 audioInputIsAvailable; | UInt32 audioInputIsAvailable; | ||||
| AudioIODeviceCallback* callback; | AudioIODeviceCallback* callback; | ||||
| BitArray activeOutputChans, activeInputChans; | |||||
| BigInteger activeOutputChans, activeInputChans; | |||||
| AudioSampleBuffer floatData; | AudioSampleBuffer floatData; | ||||
| float* inputChannels[3]; | float* inputChannels[3]; | ||||
| @@ -421,8 +421,8 @@ public: | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| const String reopen (const BitArray& inputChannels, | |||||
| const BitArray& outputChannels, | |||||
| const String reopen (const BigInteger& inputChannels, | |||||
| const BigInteger& outputChannels, | |||||
| double newSampleRate, | double newSampleRate, | ||||
| int bufferSizeSamples) | int bufferSizeSamples) | ||||
| { | { | ||||
| @@ -761,7 +761,7 @@ public: | |||||
| juce_UseDebuggingNewOperator | juce_UseDebuggingNewOperator | ||||
| int inputLatency, outputLatency; | int inputLatency, outputLatency; | ||||
| BitArray activeInputChans, activeOutputChans; | |||||
| BigInteger activeInputChans, activeOutputChans; | |||||
| StringArray inChanNames, outChanNames; | StringArray inChanNames, outChanNames; | ||||
| Array <double> sampleRates; | Array <double> sampleRates; | ||||
| Array <int> bufferSizes; | Array <int> bufferSizes; | ||||
| @@ -960,8 +960,8 @@ public: | |||||
| return 512; | return 512; | ||||
| } | } | ||||
| const String open (const BitArray& inputChannels, | |||||
| const BitArray& outputChannels, | |||||
| const String open (const BigInteger& inputChannels, | |||||
| const BigInteger& outputChannels, | |||||
| double sampleRate, | double sampleRate, | ||||
| int bufferSizeSamples) | int bufferSizeSamples) | ||||
| { | { | ||||
| @@ -1001,21 +1001,21 @@ public: | |||||
| return 32; // no way to find out, so just assume it's high.. | return 32; // no way to find out, so just assume it's high.. | ||||
| } | } | ||||
| const BitArray getActiveOutputChannels() const | |||||
| const BigInteger getActiveOutputChannels() const | |||||
| { | { | ||||
| return internal != 0 ? internal->activeOutputChans : BitArray(); | |||||
| return internal != 0 ? internal->activeOutputChans : BigInteger(); | |||||
| } | } | ||||
| const BitArray getActiveInputChannels() const | |||||
| const BigInteger getActiveInputChannels() const | |||||
| { | { | ||||
| BitArray chans; | |||||
| BigInteger chans; | |||||
| if (internal != 0) | if (internal != 0) | ||||
| { | { | ||||
| chans = internal->activeInputChans; | chans = internal->activeInputChans; | ||||
| if (internal->inputDevice != 0) | if (internal->inputDevice != 0) | ||||
| chans.orWith (internal->inputDevice->activeInputChans); | |||||
| chans |= internal->inputDevice->activeInputChans; | |||||
| } | } | ||||
| return chans; | return chans; | ||||
| @@ -186,8 +186,8 @@ public: | |||||
| return preferredSize; | return preferredSize; | ||||
| } | } | ||||
| const String open (const BitArray& inputChannels, | |||||
| const BitArray& outputChannels, | |||||
| const String open (const BigInteger& inputChannels, | |||||
| const BigInteger& outputChannels, | |||||
| double sr, | double sr, | ||||
| int bufferSizeSamples) | int bufferSizeSamples) | ||||
| { | { | ||||
| @@ -653,12 +653,12 @@ public: | |||||
| return currentSampleRate; | return currentSampleRate; | ||||
| } | } | ||||
| const BitArray getActiveOutputChannels() const | |||||
| const BigInteger getActiveOutputChannels() const | |||||
| { | { | ||||
| return currentChansOut; | return currentChansOut; | ||||
| } | } | ||||
| const BitArray getActiveInputChannels() const | |||||
| const BigInteger getActiveInputChannels() const | |||||
| { | { | ||||
| return currentChansIn; | return currentChansIn; | ||||
| } | } | ||||
| @@ -781,7 +781,7 @@ public: | |||||
| AudioIODeviceCallback* const oldCallback = currentCallback; | AudioIODeviceCallback* const oldCallback = currentCallback; | ||||
| close(); | close(); | ||||
| open (BitArray (currentChansIn), BitArray (currentChansOut), | |||||
| open (BigInteger (currentChansIn), BigInteger (currentChansOut), | |||||
| currentSampleRate, currentBlockSizeSamples); | currentSampleRate, currentBlockSizeSamples); | ||||
| if (oldCallback != 0) | if (oldCallback != 0) | ||||
| @@ -817,7 +817,7 @@ private: | |||||
| int volatile currentBlockSizeSamples; | int volatile currentBlockSizeSamples; | ||||
| int volatile currentBitDepth; | int volatile currentBitDepth; | ||||
| double volatile currentSampleRate; | double volatile currentSampleRate; | ||||
| BitArray currentChansOut, currentChansIn; | |||||
| BigInteger currentChansOut, currentChansIn; | |||||
| AudioIODeviceCallback* volatile currentCallback; | AudioIODeviceCallback* volatile currentCallback; | ||||
| CriticalSection callbackLock; | CriticalSection callbackLock; | ||||
| @@ -1030,8 +1030,8 @@ public: | |||||
| return 2560; | return 2560; | ||||
| } | } | ||||
| const String open (const BitArray& inputChannels, | |||||
| const BitArray& outputChannels, | |||||
| const String open (const BigInteger& inputChannels, | |||||
| const BigInteger& outputChannels, | |||||
| double sampleRate, | double sampleRate, | ||||
| int bufferSizeSamples) | int bufferSizeSamples) | ||||
| { | { | ||||
| @@ -1083,12 +1083,12 @@ public: | |||||
| return bits; | return bits; | ||||
| } | } | ||||
| const BitArray getActiveOutputChannels() const | |||||
| const BigInteger getActiveOutputChannels() const | |||||
| { | { | ||||
| return enabledOutputs; | return enabledOutputs; | ||||
| } | } | ||||
| const BitArray getActiveInputChannels() const | |||||
| const BigInteger getActiveInputChannels() const | |||||
| { | { | ||||
| return enabledInputs; | return enabledInputs; | ||||
| } | } | ||||
| @@ -1167,7 +1167,7 @@ private: | |||||
| int volatile totalSamplesOut; | int volatile totalSamplesOut; | ||||
| int64 volatile lastBlockTime; | int64 volatile lastBlockTime; | ||||
| double sampleRate; | double sampleRate; | ||||
| BitArray enabledInputs, enabledOutputs; | |||||
| BigInteger enabledInputs, enabledOutputs; | |||||
| HeapBlock <float*> inputBuffers, outputBuffers; | HeapBlock <float*> inputBuffers, outputBuffers; | ||||
| AudioIODeviceCallback* callback; | AudioIODeviceCallback* callback; | ||||
| @@ -1176,8 +1176,8 @@ private: | |||||
| DSoundAudioIODevice (const DSoundAudioIODevice&); | DSoundAudioIODevice (const DSoundAudioIODevice&); | ||||
| DSoundAudioIODevice& operator= (const DSoundAudioIODevice&); | DSoundAudioIODevice& operator= (const DSoundAudioIODevice&); | ||||
| const String openDevice (const BitArray& inputChannels, | |||||
| const BitArray& outputChannels, | |||||
| const String openDevice (const BigInteger& inputChannels, | |||||
| const BigInteger& outputChannels, | |||||
| double sampleRate_, | double sampleRate_, | ||||
| int bufferSizeSamples_); | int bufferSizeSamples_); | ||||
| @@ -1497,8 +1497,8 @@ private: | |||||
| }; | }; | ||||
| //============================================================================== | //============================================================================== | ||||
| const String DSoundAudioIODevice::openDevice (const BitArray& inputChannels, | |||||
| const BitArray& outputChannels, | |||||
| const String DSoundAudioIODevice::openDevice (const BigInteger& inputChannels, | |||||
| const BigInteger& outputChannels, | |||||
| double sampleRate_, | double sampleRate_, | ||||
| int bufferSizeSamples_) | int bufferSizeSamples_) | ||||
| { | { | ||||
| @@ -182,7 +182,7 @@ public: | |||||
| bool isOk() const throw() { return defaultBufferSize > 0 && defaultSampleRate > 0; } | bool isOk() const throw() { return defaultBufferSize > 0 && defaultSampleRate > 0; } | ||||
| bool openClient (const double newSampleRate, const BitArray& newChannels) | |||||
| bool openClient (const double newSampleRate, const BigInteger& newChannels) | |||||
| { | { | ||||
| sampleRate = newSampleRate; | sampleRate = newSampleRate; | ||||
| channels = newChannels; | channels = newChannels; | ||||
| @@ -232,7 +232,7 @@ public: | |||||
| const bool useExclusiveMode; | const bool useExclusiveMode; | ||||
| Array <double> rates; | Array <double> rates; | ||||
| HANDLE clientEvent; | HANDLE clientEvent; | ||||
| BitArray channels; | |||||
| BigInteger channels; | |||||
| AudioDataConverters::DataFormat dataFormat; | AudioDataConverters::DataFormat dataFormat; | ||||
| Array <int> channelMaps; | Array <int> channelMaps; | ||||
| UINT32 actualBufferSize; | UINT32 actualBufferSize; | ||||
| @@ -338,7 +338,7 @@ public: | |||||
| close(); | close(); | ||||
| } | } | ||||
| bool open (const double newSampleRate, const BitArray& newChannels) | |||||
| bool open (const double newSampleRate, const BigInteger& newChannels) | |||||
| { | { | ||||
| reservoirSize = 0; | reservoirSize = 0; | ||||
| reservoirCapacity = 16384; | reservoirCapacity = 16384; | ||||
| @@ -483,7 +483,7 @@ public: | |||||
| close(); | close(); | ||||
| } | } | ||||
| bool open (const double newSampleRate, const BitArray& newChannels) | |||||
| bool open (const double newSampleRate, const BigInteger& newChannels) | |||||
| { | { | ||||
| return openClient (newSampleRate, newChannels) | return openClient (newSampleRate, newChannels) | ||||
| && (numChannels == 0 || OK (client->GetService (__uuidof (IAudioRenderClient), (void**) &renderClient))); | && (numChannels == 0 || OK (client->GetService (__uuidof (IAudioRenderClient), (void**) &renderClient))); | ||||
| @@ -674,12 +674,12 @@ public: | |||||
| int getCurrentBitDepth() { return 32; } | int getCurrentBitDepth() { return 32; } | ||||
| int getOutputLatencyInSamples() { return latencyOut; } | int getOutputLatencyInSamples() { return latencyOut; } | ||||
| int getInputLatencyInSamples() { return latencyIn; } | int getInputLatencyInSamples() { return latencyIn; } | ||||
| const BitArray getActiveOutputChannels() const { return outputDevice != 0 ? outputDevice->channels : BitArray(); } | |||||
| const BitArray getActiveInputChannels() const { return inputDevice != 0 ? inputDevice->channels : BitArray(); } | |||||
| const BigInteger getActiveOutputChannels() const { return outputDevice != 0 ? outputDevice->channels : BigInteger(); } | |||||
| const BigInteger getActiveInputChannels() const { return inputDevice != 0 ? inputDevice->channels : BigInteger(); } | |||||
| const String getLastError() { return lastError; } | const String getLastError() { return lastError; } | ||||
| const String open (const BitArray& inputChannels, const BitArray& outputChannels, | |||||
| const String open (const BigInteger& inputChannels, const BigInteger& outputChannels, | |||||
| double sampleRate, int bufferSizeSamples) | double sampleRate, int bufferSizeSamples) | ||||
| { | { | ||||
| close(); | close(); | ||||