@@ -352,7 +352,7 @@ struct FindFileStruct | |||||
// returns 0 on failure | // returns 0 on failure | ||||
void* juce_findFileStart (const String& directory, const String& wildCard, String& firstResultFile, | void* juce_findFileStart (const String& directory, const String& wildCard, String& firstResultFile, | ||||
bool* isDir, bool* isHidden, int64* fileSize, Time* modTime, | |||||
bool* isDir, bool* isHidden, int64* fileSize, Time* modTime, | |||||
Time* creationTime, bool* isReadOnly) throw() | Time* creationTime, bool* isReadOnly) throw() | ||||
{ | { | ||||
DIR* d = opendir (directory.toUTF8()); | DIR* d = opendir (directory.toUTF8()); | ||||
@@ -53,7 +53,7 @@ WebBrowserComponent::~WebBrowserComponent() | |||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
void WebBrowserComponent::goToURL (const String& url, | |||||
void WebBrowserComponent::goToURL (const String& url, | |||||
const StringArray* headers, | const StringArray* headers, | ||||
const MemoryBlock* postData) | const MemoryBlock* postData) | ||||
{ | { | ||||
@@ -633,7 +633,7 @@ struct FindFileStruct | |||||
// returns 0 on failure | // returns 0 on failure | ||||
void* juce_findFileStart (const String& directory, const String& wildCard, String& firstResultFile, | void* juce_findFileStart (const String& directory, const String& wildCard, String& firstResultFile, | ||||
bool* isDir, bool* isHidden, int64* fileSize, Time* modTime, | |||||
bool* isDir, bool* isHidden, int64* fileSize, Time* modTime, | |||||
Time* creationTime, bool* isReadOnly) throw() | Time* creationTime, bool* isReadOnly) throw() | ||||
{ | { | ||||
DIR* const d = opendir (directory.toUTF8()); | DIR* const d = opendir (directory.toUTF8()); | ||||
@@ -142,7 +142,7 @@ public: | |||||
StringArray lines; | StringArray lines; | ||||
lines.addLines (responseHeader); | lines.addLines (responseHeader); | ||||
// NB - using charToString() here instead of just T(" "), because that was | |||||
// NB - using charToString() here instead of just T(" "), because that was | |||||
// causing a mysterious gcc internal compiler error... | // causing a mysterious gcc internal compiler error... | ||||
const int statusCode = responseHeader.fromFirstOccurrenceOf (String::charToString (T(' ')), false, false) | const int statusCode = responseHeader.fromFirstOccurrenceOf (String::charToString (T(' ')), false, false) | ||||
.substring (0, 3) | .substring (0, 3) | ||||
@@ -399,4 +399,3 @@ int juce_seekInInternetFile (void* handle, int newPosition) | |||||
return 0; | return 0; | ||||
} | } | ||||
@@ -1844,7 +1844,7 @@ public: | |||||
} | } | ||||
} | } | ||||
jassert (freeSlot >= 0); // unfortunately you can only have a finite number | |||||
jassert (freeSlot >= 0); // unfortunately you can only have a finite number | |||||
// of ASIO devices open at the same time.. | // of ASIO devices open at the same time.. | ||||
if (freeSlot >= 0) | if (freeSlot >= 0) | ||||
@@ -316,7 +316,7 @@ void WebBrowserComponent::checkWindowAssociation() | |||||
{ | { | ||||
if (browser != 0 && ! blankPageShown) | if (browser != 0 && ! blankPageShown) | ||||
{ | { | ||||
// when the component becomes invisible, some stuff like flash | |||||
// when the component becomes invisible, some stuff like flash | |||||
// carries on playing audio, so we need to force it onto a blank | // carries on playing audio, so we need to force it onto a blank | ||||
// page to avoid this.. | // page to avoid this.. | ||||
@@ -1,282 +1,282 @@ | |||||
/* | |||||
============================================================================== | |||||
This file is part of the JUCE library - "Jules' Utility Class Extensions" | |||||
Copyright 2004-7 by Raw Material Software ltd. | |||||
------------------------------------------------------------------------------ | |||||
JUCE can be redistributed and/or modified under the terms of the | |||||
GNU General Public License, as published by the Free Software Foundation; | |||||
either version 2 of the License, or (at your option) any later version. | |||||
JUCE is distributed in the hope that it will be useful, | |||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
GNU General Public License for more details. | |||||
You should have received a copy of the GNU General Public License | |||||
along with JUCE; if not, visit www.gnu.org/licenses or write to the | |||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330, | |||||
Boston, MA 02111-1307 USA | |||||
------------------------------------------------------------------------------ | |||||
If you'd like to release a closed-source product which uses JUCE, commercial | |||||
licenses are also available: visit www.rawmaterialsoftware.com/juce for | |||||
more information. | |||||
============================================================================== | |||||
*/ | |||||
#ifndef __JUCE_FILTERGRAPH_JUCEHEADER__ | |||||
#define __JUCE_FILTERGRAPH_JUCEHEADER__ | |||||
class FilterInGraph; | |||||
class FilterGraph; | |||||
const char* const filenameSuffix = ".filtergraph"; | |||||
const char* const filenameWildcard = "*.filtergraph"; | |||||
//============================================================================== | |||||
/** | |||||
Represents a connection between two pins in a FilterGraph. | |||||
*/ | |||||
class FilterConnection | |||||
{ | |||||
public: | |||||
//============================================================================== | |||||
FilterConnection (FilterGraph& owner); | |||||
FilterConnection (const FilterConnection& other); | |||||
~FilterConnection(); | |||||
//============================================================================== | |||||
uint32 sourceFilterID; | |||||
int sourceChannel; | |||||
uint32 destFilterID; | |||||
int destChannel; | |||||
//============================================================================== | |||||
juce_UseDebuggingNewOperator | |||||
private: | |||||
FilterGraph& owner; | |||||
const FilterConnection& operator= (const FilterConnection&); | |||||
}; | |||||
//============================================================================== | |||||
/** | |||||
Represents one of the filters in a FilterGraph. | |||||
*/ | |||||
/*class FilterInGraph : public ReferenceCountedObject | |||||
{ | |||||
public: | |||||
//============================================================================== | |||||
FilterInGraph (FilterGraph& owner, AudioPluginInstance* const plugin); | |||||
~FilterInGraph(); | |||||
//============================================================================== | |||||
AudioPluginInstance* const filter; | |||||
uint32 uid; | |||||
//============================================================================== | |||||
void showUI (bool useGenericUI); | |||||
double getX() const throw() { return x; } | |||||
double getY() const throw() { return y; } | |||||
void setPosition (double x, double y) throw(); | |||||
XmlElement* createXml() const; | |||||
static FilterInGraph* createForDescription (FilterGraph& owner, | |||||
const PluginDescription& desc, | |||||
String& errorMessage); | |||||
static FilterInGraph* createFromXml (FilterGraph& owner, const XmlElement& xml); | |||||
//============================================================================== | |||||
typedef ReferenceCountedObjectPtr <FilterInGraph> Ptr; | |||||
//============================================================================== | |||||
juce_UseDebuggingNewOperator | |||||
private: | |||||
friend class FilterGraphPlayer; | |||||
FilterGraph& owner; | |||||
double x, y; | |||||
friend class PluginWindow; | |||||
Component* activeUI; | |||||
Component* activeGenericUI; | |||||
int lastX, lastY; | |||||
MidiBuffer outputMidi; | |||||
AudioSampleBuffer processedAudio; | |||||
MidiBuffer processedMidi; | |||||
void prepareBuffers (int blockSize); | |||||
void renderBlock (int numSamples, | |||||
const ReferenceCountedArray <FilterInGraph>& filters, | |||||
const OwnedArray <FilterConnection>& connections); | |||||
FilterInGraph (const FilterInGraph&); | |||||
const FilterInGraph& operator= (const FilterInGraph&); | |||||
}; | |||||
*/ | |||||
//============================================================================== | |||||
/** | |||||
A collection of filters and some connections between them. | |||||
*/ | |||||
class FilterGraph : public FileBasedDocument | |||||
{ | |||||
public: | |||||
//============================================================================== | |||||
FilterGraph(); | |||||
~FilterGraph(); | |||||
//============================================================================== | |||||
AudioProcessorGraph& getGraph() throw() { return graph; } | |||||
int getNumFilters() const throw(); | |||||
const AudioProcessorGraph::Node::Ptr getNode (const int index) const throw(); | |||||
const AudioProcessorGraph::Node::Ptr getNodeForId (const uint32 uid) const throw(); | |||||
void addFilter (const PluginDescription* desc, double x, double y); | |||||
void removeFilter (const uint32 filterUID); | |||||
void disconnectFilter (const uint32 filterUID); | |||||
void removeIllegalConnections(); | |||||
void setNodePosition (const int nodeId, double x, double y); | |||||
void getNodePosition (const int nodeId, double& x, double& y) const; | |||||
//============================================================================== | |||||
int getNumConnections() const throw(); | |||||
const AudioProcessorGraph::Connection* getConnection (const int index) const throw(); | |||||
const AudioProcessorGraph::Connection* getConnectionBetween (uint32 sourceFilterUID, int sourceFilterChannel, | |||||
uint32 destFilterUID, int destFilterChannel) const throw(); | |||||
bool canConnect (uint32 sourceFilterUID, int sourceFilterChannel, | |||||
uint32 destFilterUID, int destFilterChannel) const throw(); | |||||
bool addConnection (uint32 sourceFilterUID, int sourceFilterChannel, | |||||
uint32 destFilterUID, int destFilterChannel); | |||||
void removeConnection (const int index); | |||||
void removeConnection (uint32 sourceFilterUID, int sourceFilterChannel, | |||||
uint32 destFilterUID, int destFilterChannel); | |||||
void clear(); | |||||
//============================================================================== | |||||
XmlElement* createXml() const; | |||||
void restoreFromXml (const XmlElement& xml); | |||||
//============================================================================== | |||||
const String getDocumentTitle(); | |||||
const String loadDocument (const File& file); | |||||
const String saveDocument (const File& file); | |||||
const File getLastDocumentOpened(); | |||||
void setLastDocumentOpened (const File& file); | |||||
/** The special channel index used to refer to a filter's midi channel. | |||||
*/ | |||||
static const int midiChannelNumber; | |||||
//============================================================================== | |||||
juce_UseDebuggingNewOperator | |||||
private: | |||||
//friend class FilterGraphPlayer; | |||||
//ReferenceCountedArray <FilterInGraph> filters; | |||||
//OwnedArray <FilterConnection> connections; | |||||
AudioProcessorGraph graph; | |||||
AudioProcessorPlayer player; | |||||
uint32 lastUID; | |||||
uint32 getNextUID() throw(); | |||||
void createNodeFromXml (const XmlElement& xml); | |||||
FilterGraph (const FilterGraph&); | |||||
const FilterGraph& operator= (const FilterGraph&); | |||||
}; | |||||
//============================================================================== | |||||
/** | |||||
*/ | |||||
/*class FilterGraphPlayer : public AudioIODeviceCallback, | |||||
public MidiInputCallback, | |||||
public ChangeListener | |||||
{ | |||||
public: | |||||
//============================================================================== | |||||
FilterGraphPlayer (FilterGraph& graph); | |||||
~FilterGraphPlayer(); | |||||
//============================================================================== | |||||
void setAudioDeviceManager (AudioDeviceManager* dm); | |||||
AudioDeviceManager* getAudioDeviceManager() const throw() { return deviceManager; } | |||||
//============================================================================== | |||||
void audioDeviceIOCallback (const float** inputChannelData, | |||||
int totalNumInputChannels, | |||||
float** outputChannelData, | |||||
int totalNumOutputChannels, | |||||
int numSamples); | |||||
void audioDeviceAboutToStart (double sampleRate, int numSamplesPerBlock); | |||||
void audioDeviceStopped(); | |||||
void handleIncomingMidiMessage (MidiInput* source, const MidiMessage& message); | |||||
void changeListenerCallback (void*); | |||||
//============================================================================== | |||||
static int compareElements (FilterInGraph* const first, FilterInGraph* const second) throw(); | |||||
const float** inputChannelData; | |||||
int totalNumInputChannels; | |||||
float** outputChannelData; | |||||
int totalNumOutputChannels; | |||||
MidiBuffer incomingMidi; | |||||
MidiKeyboardState keyState; | |||||
MidiMessageCollector messageCollector; | |||||
//============================================================================== | |||||
class PlayerAwareFilter | |||||
{ | |||||
public: | |||||
virtual void setPlayer (FilterGraphPlayer* newPlayer) = 0; | |||||
}; | |||||
private: | |||||
FilterGraph& graph; | |||||
CriticalSection processLock; | |||||
double sampleRate; | |||||
int blockSize; | |||||
AudioDeviceManager* deviceManager; | |||||
ReferenceCountedArray <FilterInGraph> filters; | |||||
OwnedArray <FilterConnection> connections; | |||||
void update(); | |||||
FilterGraphPlayer (const FilterGraphPlayer&); | |||||
const FilterGraphPlayer& operator= (const FilterGraphPlayer&); | |||||
}; | |||||
*/ | |||||
#endif | |||||
/* | |||||
============================================================================== | |||||
This file is part of the JUCE library - "Jules' Utility Class Extensions" | |||||
Copyright 2004-7 by Raw Material Software ltd. | |||||
------------------------------------------------------------------------------ | |||||
JUCE can be redistributed and/or modified under the terms of the | |||||
GNU General Public License, as published by the Free Software Foundation; | |||||
either version 2 of the License, or (at your option) any later version. | |||||
JUCE is distributed in the hope that it will be useful, | |||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
GNU General Public License for more details. | |||||
You should have received a copy of the GNU General Public License | |||||
along with JUCE; if not, visit www.gnu.org/licenses or write to the | |||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330, | |||||
Boston, MA 02111-1307 USA | |||||
------------------------------------------------------------------------------ | |||||
If you'd like to release a closed-source product which uses JUCE, commercial | |||||
licenses are also available: visit www.rawmaterialsoftware.com/juce for | |||||
more information. | |||||
============================================================================== | |||||
*/ | |||||
#ifndef __JUCE_FILTERGRAPH_JUCEHEADER__ | |||||
#define __JUCE_FILTERGRAPH_JUCEHEADER__ | |||||
class FilterInGraph; | |||||
class FilterGraph; | |||||
const char* const filenameSuffix = ".filtergraph"; | |||||
const char* const filenameWildcard = "*.filtergraph"; | |||||
//============================================================================== | |||||
/** | |||||
Represents a connection between two pins in a FilterGraph. | |||||
*/ | |||||
class FilterConnection | |||||
{ | |||||
public: | |||||
//============================================================================== | |||||
FilterConnection (FilterGraph& owner); | |||||
FilterConnection (const FilterConnection& other); | |||||
~FilterConnection(); | |||||
//============================================================================== | |||||
uint32 sourceFilterID; | |||||
int sourceChannel; | |||||
uint32 destFilterID; | |||||
int destChannel; | |||||
//============================================================================== | |||||
juce_UseDebuggingNewOperator | |||||
private: | |||||
FilterGraph& owner; | |||||
const FilterConnection& operator= (const FilterConnection&); | |||||
}; | |||||
//============================================================================== | |||||
/** | |||||
Represents one of the filters in a FilterGraph. | |||||
*/ | |||||
/*class FilterInGraph : public ReferenceCountedObject | |||||
{ | |||||
public: | |||||
//============================================================================== | |||||
FilterInGraph (FilterGraph& owner, AudioPluginInstance* const plugin); | |||||
~FilterInGraph(); | |||||
//============================================================================== | |||||
AudioPluginInstance* const filter; | |||||
uint32 uid; | |||||
//============================================================================== | |||||
void showUI (bool useGenericUI); | |||||
double getX() const throw() { return x; } | |||||
double getY() const throw() { return y; } | |||||
void setPosition (double x, double y) throw(); | |||||
XmlElement* createXml() const; | |||||
static FilterInGraph* createForDescription (FilterGraph& owner, | |||||
const PluginDescription& desc, | |||||
String& errorMessage); | |||||
static FilterInGraph* createFromXml (FilterGraph& owner, const XmlElement& xml); | |||||
//============================================================================== | |||||
typedef ReferenceCountedObjectPtr <FilterInGraph> Ptr; | |||||
//============================================================================== | |||||
juce_UseDebuggingNewOperator | |||||
private: | |||||
friend class FilterGraphPlayer; | |||||
FilterGraph& owner; | |||||
double x, y; | |||||
friend class PluginWindow; | |||||
Component* activeUI; | |||||
Component* activeGenericUI; | |||||
int lastX, lastY; | |||||
MidiBuffer outputMidi; | |||||
AudioSampleBuffer processedAudio; | |||||
MidiBuffer processedMidi; | |||||
void prepareBuffers (int blockSize); | |||||
void renderBlock (int numSamples, | |||||
const ReferenceCountedArray <FilterInGraph>& filters, | |||||
const OwnedArray <FilterConnection>& connections); | |||||
FilterInGraph (const FilterInGraph&); | |||||
const FilterInGraph& operator= (const FilterInGraph&); | |||||
}; | |||||
*/ | |||||
//============================================================================== | |||||
/** | |||||
A collection of filters and some connections between them. | |||||
*/ | |||||
class FilterGraph : public FileBasedDocument | |||||
{ | |||||
public: | |||||
//============================================================================== | |||||
FilterGraph(); | |||||
~FilterGraph(); | |||||
//============================================================================== | |||||
AudioProcessorGraph& getGraph() throw() { return graph; } | |||||
int getNumFilters() const throw(); | |||||
const AudioProcessorGraph::Node::Ptr getNode (const int index) const throw(); | |||||
const AudioProcessorGraph::Node::Ptr getNodeForId (const uint32 uid) const throw(); | |||||
void addFilter (const PluginDescription* desc, double x, double y); | |||||
void removeFilter (const uint32 filterUID); | |||||
void disconnectFilter (const uint32 filterUID); | |||||
void removeIllegalConnections(); | |||||
void setNodePosition (const int nodeId, double x, double y); | |||||
void getNodePosition (const int nodeId, double& x, double& y) const; | |||||
//============================================================================== | |||||
int getNumConnections() const throw(); | |||||
const AudioProcessorGraph::Connection* getConnection (const int index) const throw(); | |||||
const AudioProcessorGraph::Connection* getConnectionBetween (uint32 sourceFilterUID, int sourceFilterChannel, | |||||
uint32 destFilterUID, int destFilterChannel) const throw(); | |||||
bool canConnect (uint32 sourceFilterUID, int sourceFilterChannel, | |||||
uint32 destFilterUID, int destFilterChannel) const throw(); | |||||
bool addConnection (uint32 sourceFilterUID, int sourceFilterChannel, | |||||
uint32 destFilterUID, int destFilterChannel); | |||||
void removeConnection (const int index); | |||||
void removeConnection (uint32 sourceFilterUID, int sourceFilterChannel, | |||||
uint32 destFilterUID, int destFilterChannel); | |||||
void clear(); | |||||
//============================================================================== | |||||
XmlElement* createXml() const; | |||||
void restoreFromXml (const XmlElement& xml); | |||||
//============================================================================== | |||||
const String getDocumentTitle(); | |||||
const String loadDocument (const File& file); | |||||
const String saveDocument (const File& file); | |||||
const File getLastDocumentOpened(); | |||||
void setLastDocumentOpened (const File& file); | |||||
/** The special channel index used to refer to a filter's midi channel. | |||||
*/ | |||||
static const int midiChannelNumber; | |||||
//============================================================================== | |||||
juce_UseDebuggingNewOperator | |||||
private: | |||||
//friend class FilterGraphPlayer; | |||||
//ReferenceCountedArray <FilterInGraph> filters; | |||||
//OwnedArray <FilterConnection> connections; | |||||
AudioProcessorGraph graph; | |||||
AudioProcessorPlayer player; | |||||
uint32 lastUID; | |||||
uint32 getNextUID() throw(); | |||||
void createNodeFromXml (const XmlElement& xml); | |||||
FilterGraph (const FilterGraph&); | |||||
const FilterGraph& operator= (const FilterGraph&); | |||||
}; | |||||
//============================================================================== | |||||
/** | |||||
*/ | |||||
/*class FilterGraphPlayer : public AudioIODeviceCallback, | |||||
public MidiInputCallback, | |||||
public ChangeListener | |||||
{ | |||||
public: | |||||
//============================================================================== | |||||
FilterGraphPlayer (FilterGraph& graph); | |||||
~FilterGraphPlayer(); | |||||
//============================================================================== | |||||
void setAudioDeviceManager (AudioDeviceManager* dm); | |||||
AudioDeviceManager* getAudioDeviceManager() const throw() { return deviceManager; } | |||||
//============================================================================== | |||||
void audioDeviceIOCallback (const float** inputChannelData, | |||||
int totalNumInputChannels, | |||||
float** outputChannelData, | |||||
int totalNumOutputChannels, | |||||
int numSamples); | |||||
void audioDeviceAboutToStart (double sampleRate, int numSamplesPerBlock); | |||||
void audioDeviceStopped(); | |||||
void handleIncomingMidiMessage (MidiInput* source, const MidiMessage& message); | |||||
void changeListenerCallback (void*); | |||||
//============================================================================== | |||||
static int compareElements (FilterInGraph* const first, FilterInGraph* const second) throw(); | |||||
const float** inputChannelData; | |||||
int totalNumInputChannels; | |||||
float** outputChannelData; | |||||
int totalNumOutputChannels; | |||||
MidiBuffer incomingMidi; | |||||
MidiKeyboardState keyState; | |||||
MidiMessageCollector messageCollector; | |||||
//============================================================================== | |||||
class PlayerAwareFilter | |||||
{ | |||||
public: | |||||
virtual void setPlayer (FilterGraphPlayer* newPlayer) = 0; | |||||
}; | |||||
private: | |||||
FilterGraph& graph; | |||||
CriticalSection processLock; | |||||
double sampleRate; | |||||
int blockSize; | |||||
AudioDeviceManager* deviceManager; | |||||
ReferenceCountedArray <FilterInGraph> filters; | |||||
OwnedArray <FilterConnection> connections; | |||||
void update(); | |||||
FilterGraphPlayer (const FilterGraphPlayer&); | |||||
const FilterGraphPlayer& operator= (const FilterGraphPlayer&); | |||||
}; | |||||
*/ | |||||
#endif |
@@ -30,7 +30,7 @@ | |||||
*/ | */ | ||||
/* | /* | ||||
This file contains settings that you might want to explicitly apply to | |||||
This file contains settings that you might want to explicitly apply to | |||||
the your build. | the your build. | ||||
Most of these are turned on or off by default, but you can override | Most of these are turned on or off by default, but you can override | ||||
@@ -1,10 +1,10 @@ | |||||
/* | |||||
/* | |||||
This file includes the entire juce source tree via the amalgamated file. | This file includes the entire juce source tree via the amalgamated file. | ||||
You could add the amalgamated file directly to your project, but doing it | You could add the amalgamated file directly to your project, but doing it | ||||
like this allows you to put your app's config settings in the | |||||
juce_AppConfig.h file and have them applied to both the juce headers and | |||||
like this allows you to put your app's config settings in the | |||||
juce_AppConfig.h file and have them applied to both the juce headers and | |||||
the source code. | the source code. | ||||
*/ | */ | ||||
@@ -7969,4 +7969,3 @@ static const unsigned char temp17[] = {47,42,13,10,32,32,61,61,61,61,61,61,61,61 | |||||
111,109,109,97,110,100,77,97,110,97,103,101,114,41,13,10,123,13,10,32,32,32,32,114,101,116,117,114,110,32,110,101,119,32,87,105,100,103,101,116, | 111,109,109,97,110,100,77,97,110,97,103,101,114,41,13,10,123,13,10,32,32,32,32,114,101,116,117,114,110,32,110,101,119,32,87,105,100,103,101,116, | ||||
115,68,101,109,111,32,40,99,111,109,109,97,110,100,77,97,110,97,103,101,114,41,59,13,10,125,13,10,0,0}; | 115,68,101,109,111,32,40,99,111,109,109,97,110,100,77,97,110,97,103,101,114,41,59,13,10,125,13,10,0,0}; | ||||
const char* BinaryData::widgetsdemo_cpp = (const char*) temp17; | const char* BinaryData::widgetsdemo_cpp = (const char*) temp17; | ||||
@@ -1,129 +1,129 @@ | |||||
/* | |||||
============================================================================== | |||||
This file is part of the JUCE library - "Jules' Utility Class Extensions" | |||||
Copyright 2004-7 by Raw Material Software ltd. | |||||
------------------------------------------------------------------------------ | |||||
JUCE can be redistributed and/or modified under the terms of the | |||||
GNU General Public License, as published by the Free Software Foundation; | |||||
either version 2 of the License, or (at your option) any later version. | |||||
JUCE is distributed in the hope that it will be useful, | |||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
GNU General Public License for more details. | |||||
You should have received a copy of the GNU General Public License | |||||
along with JUCE; if not, visit www.gnu.org/licenses or write to the | |||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330, | |||||
Boston, MA 02111-1307 USA | |||||
------------------------------------------------------------------------------ | |||||
If you'd like to release a closed-source product which uses JUCE, commercial | |||||
licenses are also available: visit www.rawmaterialsoftware.com/juce for | |||||
more information. | |||||
============================================================================== | |||||
*/ | |||||
#include "../jucedemo_headers.h" | |||||
#if JUCE_QUICKTIME && ! JUCE_LINUX | |||||
//============================================================================== | |||||
// so that we can easily have two QT windows each with a file browser, wrap this up as a class.. | |||||
class QuickTimeWindowWithFileBrowser : public Component, | |||||
public FilenameComponentListener | |||||
{ | |||||
public: | |||||
QuickTimeWindowWithFileBrowser() | |||||
{ | |||||
addAndMakeVisible (qtComp = new QuickTimeMovieComponent()); | |||||
// and a file-chooser.. | |||||
addAndMakeVisible (fileChooser = new FilenameComponent (T("movie"), | |||||
File::nonexistent, | |||||
true, false, false, | |||||
T("*.*"), | |||||
String::empty, | |||||
T("(choose a video file to play)"))); | |||||
fileChooser->addListener (this); | |||||
fileChooser->setBrowseButtonText (T("browse")); | |||||
} | |||||
~QuickTimeWindowWithFileBrowser() | |||||
{ | |||||
deleteAllChildren(); | |||||
} | |||||
void resized() | |||||
{ | |||||
qtComp->setBounds (0, 0, getWidth(), getHeight() - 30); | |||||
fileChooser->setBounds (0, getHeight() - 24, getWidth(), 24); | |||||
} | |||||
void filenameComponentChanged (FilenameComponent*) | |||||
{ | |||||
// this is called when the user changes the filename in the file chooser box | |||||
if (qtComp->loadMovie (fileChooser->getCurrentFile(), true)) | |||||
{ | |||||
// loaded the file ok, so let's start it playing.. | |||||
qtComp->play(); | |||||
} | |||||
else | |||||
{ | |||||
AlertWindow::showMessageBox (AlertWindow::WarningIcon, | |||||
T("Couldn't load the file!"), | |||||
T("Sorry, QuickTime didn't manage to load that file!")); | |||||
} | |||||
} | |||||
private: | |||||
QuickTimeMovieComponent* qtComp; | |||||
FilenameComponent* fileChooser; | |||||
}; | |||||
//============================================================================== | |||||
class QuickTimeDemo : public Component | |||||
{ | |||||
public: | |||||
//============================================================================== | |||||
QuickTimeDemo() | |||||
{ | |||||
setName (T("QuickTime")); | |||||
// add a movie component.. | |||||
addAndMakeVisible (qtComp1 = new QuickTimeWindowWithFileBrowser()); | |||||
addAndMakeVisible (qtComp2 = new QuickTimeWindowWithFileBrowser()); | |||||
} | |||||
~QuickTimeDemo() | |||||
{ | |||||
deleteAllChildren(); | |||||
} | |||||
void resized() | |||||
{ | |||||
qtComp1->setBoundsRelative (0.05f, 0.05f, 0.425f, 0.9f); | |||||
qtComp2->setBoundsRelative (0.525f, 0.05f, 0.425f, 0.9f); | |||||
} | |||||
private: | |||||
//============================================================================== | |||||
QuickTimeWindowWithFileBrowser* qtComp1; | |||||
QuickTimeWindowWithFileBrowser* qtComp2; | |||||
}; | |||||
//============================================================================== | |||||
Component* createQuickTimeDemo() | |||||
{ | |||||
return new QuickTimeDemo(); | |||||
} | |||||
#endif | |||||
/* | |||||
============================================================================== | |||||
This file is part of the JUCE library - "Jules' Utility Class Extensions" | |||||
Copyright 2004-7 by Raw Material Software ltd. | |||||
------------------------------------------------------------------------------ | |||||
JUCE can be redistributed and/or modified under the terms of the | |||||
GNU General Public License, as published by the Free Software Foundation; | |||||
either version 2 of the License, or (at your option) any later version. | |||||
JUCE is distributed in the hope that it will be useful, | |||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
GNU General Public License for more details. | |||||
You should have received a copy of the GNU General Public License | |||||
along with JUCE; if not, visit www.gnu.org/licenses or write to the | |||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330, | |||||
Boston, MA 02111-1307 USA | |||||
------------------------------------------------------------------------------ | |||||
If you'd like to release a closed-source product which uses JUCE, commercial | |||||
licenses are also available: visit www.rawmaterialsoftware.com/juce for | |||||
more information. | |||||
============================================================================== | |||||
*/ | |||||
#include "../jucedemo_headers.h" | |||||
#if JUCE_QUICKTIME && ! JUCE_LINUX | |||||
//============================================================================== | |||||
// so that we can easily have two QT windows each with a file browser, wrap this up as a class.. | |||||
class QuickTimeWindowWithFileBrowser : public Component, | |||||
public FilenameComponentListener | |||||
{ | |||||
public: | |||||
QuickTimeWindowWithFileBrowser() | |||||
{ | |||||
addAndMakeVisible (qtComp = new QuickTimeMovieComponent()); | |||||
// and a file-chooser.. | |||||
addAndMakeVisible (fileChooser = new FilenameComponent (T("movie"), | |||||
File::nonexistent, | |||||
true, false, false, | |||||
T("*.*"), | |||||
String::empty, | |||||
T("(choose a video file to play)"))); | |||||
fileChooser->addListener (this); | |||||
fileChooser->setBrowseButtonText (T("browse")); | |||||
} | |||||
~QuickTimeWindowWithFileBrowser() | |||||
{ | |||||
deleteAllChildren(); | |||||
} | |||||
void resized() | |||||
{ | |||||
qtComp->setBounds (0, 0, getWidth(), getHeight() - 30); | |||||
fileChooser->setBounds (0, getHeight() - 24, getWidth(), 24); | |||||
} | |||||
void filenameComponentChanged (FilenameComponent*) | |||||
{ | |||||
// this is called when the user changes the filename in the file chooser box | |||||
if (qtComp->loadMovie (fileChooser->getCurrentFile(), true)) | |||||
{ | |||||
// loaded the file ok, so let's start it playing.. | |||||
qtComp->play(); | |||||
} | |||||
else | |||||
{ | |||||
AlertWindow::showMessageBox (AlertWindow::WarningIcon, | |||||
T("Couldn't load the file!"), | |||||
T("Sorry, QuickTime didn't manage to load that file!")); | |||||
} | |||||
} | |||||
private: | |||||
QuickTimeMovieComponent* qtComp; | |||||
FilenameComponent* fileChooser; | |||||
}; | |||||
//============================================================================== | |||||
class QuickTimeDemo : public Component | |||||
{ | |||||
public: | |||||
//============================================================================== | |||||
QuickTimeDemo() | |||||
{ | |||||
setName (T("QuickTime")); | |||||
// add a movie component.. | |||||
addAndMakeVisible (qtComp1 = new QuickTimeWindowWithFileBrowser()); | |||||
addAndMakeVisible (qtComp2 = new QuickTimeWindowWithFileBrowser()); | |||||
} | |||||
~QuickTimeDemo() | |||||
{ | |||||
deleteAllChildren(); | |||||
} | |||||
void resized() | |||||
{ | |||||
qtComp1->setBoundsRelative (0.05f, 0.05f, 0.425f, 0.9f); | |||||
qtComp2->setBoundsRelative (0.525f, 0.05f, 0.425f, 0.9f); | |||||
} | |||||
private: | |||||
//============================================================================== | |||||
QuickTimeWindowWithFileBrowser* qtComp1; | |||||
QuickTimeWindowWithFileBrowser* qtComp2; | |||||
}; | |||||
//============================================================================== | |||||
Component* createQuickTimeDemo() | |||||
{ | |||||
return new QuickTimeDemo(); | |||||
} | |||||
#endif |
@@ -1,129 +1,129 @@ | |||||
/* | |||||
============================================================================== | |||||
This file is part of the JUCE library - "Jules' Utility Class Extensions" | |||||
Copyright 2004-7 by Raw Material Software ltd. | |||||
------------------------------------------------------------------------------ | |||||
JUCE can be redistributed and/or modified under the terms of the | |||||
GNU General Public License, as published by the Free Software Foundation; | |||||
either version 2 of the License, or (at your option) any later version. | |||||
JUCE is distributed in the hope that it will be useful, | |||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
GNU General Public License for more details. | |||||
You should have received a copy of the GNU General Public License | |||||
along with JUCE; if not, visit www.gnu.org/licenses or write to the | |||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330, | |||||
Boston, MA 02111-1307 USA | |||||
------------------------------------------------------------------------------ | |||||
If you'd like to release a closed-source product which uses JUCE, commercial | |||||
licenses are also available: visit www.rawmaterialsoftware.com/juce for | |||||
more information. | |||||
============================================================================== | |||||
*/ | |||||
#include "../jucedemo_headers.h" | |||||
#if JUCE_QUICKTIME && ! JUCE_LINUX | |||||
//============================================================================== | |||||
// so that we can easily have two QT windows each with a file browser, wrap this up as a class.. | |||||
class QuickTimeWindowWithFileBrowser : public Component, | |||||
public FilenameComponentListener | |||||
{ | |||||
public: | |||||
QuickTimeWindowWithFileBrowser() | |||||
{ | |||||
addAndMakeVisible (qtComp = new QuickTimeMovieComponent()); | |||||
// and a file-chooser.. | |||||
addAndMakeVisible (fileChooser = new FilenameComponent (T("movie"), | |||||
File::nonexistent, | |||||
true, false, false, | |||||
T("*.*"), | |||||
String::empty, | |||||
T("(choose a video file to play)"))); | |||||
fileChooser->addListener (this); | |||||
fileChooser->setBrowseButtonText (T("browse")); | |||||
} | |||||
~QuickTimeWindowWithFileBrowser() | |||||
{ | |||||
deleteAllChildren(); | |||||
} | |||||
void resized() | |||||
{ | |||||
qtComp->setBounds (0, 0, getWidth(), getHeight() - 30); | |||||
fileChooser->setBounds (0, getHeight() - 24, getWidth(), 24); | |||||
} | |||||
void filenameComponentChanged (FilenameComponent*) | |||||
{ | |||||
// this is called when the user changes the filename in the file chooser box | |||||
if (qtComp->loadMovie (fileChooser->getCurrentFile(), true)) | |||||
{ | |||||
// loaded the file ok, so let's start it playing.. | |||||
qtComp->play(); | |||||
} | |||||
else | |||||
{ | |||||
AlertWindow::showMessageBox (AlertWindow::WarningIcon, | |||||
T("Couldn't load the file!"), | |||||
T("Sorry, QuickTime didn't manage to load that file!")); | |||||
} | |||||
} | |||||
private: | |||||
QuickTimeMovieComponent* qtComp; | |||||
FilenameComponent* fileChooser; | |||||
}; | |||||
//============================================================================== | |||||
class QuickTimeDemo : public Component | |||||
{ | |||||
public: | |||||
//============================================================================== | |||||
QuickTimeDemo() | |||||
{ | |||||
setName (T("QuickTime")); | |||||
// add a movie component.. | |||||
addAndMakeVisible (qtComp1 = new QuickTimeWindowWithFileBrowser()); | |||||
addAndMakeVisible (qtComp2 = new QuickTimeWindowWithFileBrowser()); | |||||
} | |||||
~QuickTimeDemo() | |||||
{ | |||||
deleteAllChildren(); | |||||
} | |||||
void resized() | |||||
{ | |||||
qtComp1->setBoundsRelative (0.05f, 0.05f, 0.425f, 0.9f); | |||||
qtComp2->setBoundsRelative (0.525f, 0.05f, 0.425f, 0.9f); | |||||
} | |||||
private: | |||||
//============================================================================== | |||||
QuickTimeWindowWithFileBrowser* qtComp1; | |||||
QuickTimeWindowWithFileBrowser* qtComp2; | |||||
}; | |||||
//============================================================================== | |||||
Component* createQuickTimeDemo() | |||||
{ | |||||
return new QuickTimeDemo(); | |||||
} | |||||
#endif | |||||
/* | |||||
============================================================================== | |||||
This file is part of the JUCE library - "Jules' Utility Class Extensions" | |||||
Copyright 2004-7 by Raw Material Software ltd. | |||||
------------------------------------------------------------------------------ | |||||
JUCE can be redistributed and/or modified under the terms of the | |||||
GNU General Public License, as published by the Free Software Foundation; | |||||
either version 2 of the License, or (at your option) any later version. | |||||
JUCE is distributed in the hope that it will be useful, | |||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
GNU General Public License for more details. | |||||
You should have received a copy of the GNU General Public License | |||||
along with JUCE; if not, visit www.gnu.org/licenses or write to the | |||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330, | |||||
Boston, MA 02111-1307 USA | |||||
------------------------------------------------------------------------------ | |||||
If you'd like to release a closed-source product which uses JUCE, commercial | |||||
licenses are also available: visit www.rawmaterialsoftware.com/juce for | |||||
more information. | |||||
============================================================================== | |||||
*/ | |||||
#include "../jucedemo_headers.h" | |||||
#if JUCE_QUICKTIME && ! JUCE_LINUX | |||||
//============================================================================== | |||||
// so that we can easily have two QT windows each with a file browser, wrap this up as a class.. | |||||
class QuickTimeWindowWithFileBrowser : public Component, | |||||
public FilenameComponentListener | |||||
{ | |||||
public: | |||||
QuickTimeWindowWithFileBrowser() | |||||
{ | |||||
addAndMakeVisible (qtComp = new QuickTimeMovieComponent()); | |||||
// and a file-chooser.. | |||||
addAndMakeVisible (fileChooser = new FilenameComponent (T("movie"), | |||||
File::nonexistent, | |||||
true, false, false, | |||||
T("*.*"), | |||||
String::empty, | |||||
T("(choose a video file to play)"))); | |||||
fileChooser->addListener (this); | |||||
fileChooser->setBrowseButtonText (T("browse")); | |||||
} | |||||
~QuickTimeWindowWithFileBrowser() | |||||
{ | |||||
deleteAllChildren(); | |||||
} | |||||
void resized() | |||||
{ | |||||
qtComp->setBounds (0, 0, getWidth(), getHeight() - 30); | |||||
fileChooser->setBounds (0, getHeight() - 24, getWidth(), 24); | |||||
} | |||||
void filenameComponentChanged (FilenameComponent*) | |||||
{ | |||||
// this is called when the user changes the filename in the file chooser box | |||||
if (qtComp->loadMovie (fileChooser->getCurrentFile(), true)) | |||||
{ | |||||
// loaded the file ok, so let's start it playing.. | |||||
qtComp->play(); | |||||
} | |||||
else | |||||
{ | |||||
AlertWindow::showMessageBox (AlertWindow::WarningIcon, | |||||
T("Couldn't load the file!"), | |||||
T("Sorry, QuickTime didn't manage to load that file!")); | |||||
} | |||||
} | |||||
private: | |||||
QuickTimeMovieComponent* qtComp; | |||||
FilenameComponent* fileChooser; | |||||
}; | |||||
//============================================================================== | |||||
class QuickTimeDemo : public Component | |||||
{ | |||||
public: | |||||
//============================================================================== | |||||
QuickTimeDemo() | |||||
{ | |||||
setName (T("QuickTime")); | |||||
// add a movie component.. | |||||
addAndMakeVisible (qtComp1 = new QuickTimeWindowWithFileBrowser()); | |||||
addAndMakeVisible (qtComp2 = new QuickTimeWindowWithFileBrowser()); | |||||
} | |||||
~QuickTimeDemo() | |||||
{ | |||||
deleteAllChildren(); | |||||
} | |||||
void resized() | |||||
{ | |||||
qtComp1->setBoundsRelative (0.05f, 0.05f, 0.425f, 0.9f); | |||||
qtComp2->setBoundsRelative (0.525f, 0.05f, 0.425f, 0.9f); | |||||
} | |||||
private: | |||||
//============================================================================== | |||||
QuickTimeWindowWithFileBrowser* qtComp1; | |||||
QuickTimeWindowWithFileBrowser* qtComp2; | |||||
}; | |||||
//============================================================================== | |||||
Component* createQuickTimeDemo() | |||||
{ | |||||
return new QuickTimeDemo(); | |||||
} | |||||
#endif |
@@ -30,7 +30,7 @@ | |||||
*/ | */ | ||||
/* | /* | ||||
This file contains settings that you might want to explicitly apply to | |||||
This file contains settings that you might want to explicitly apply to | |||||
the your build. | the your build. | ||||
Most of these are turned on or off by default, but you can override | Most of these are turned on or off by default, but you can override | ||||
@@ -1,10 +1,10 @@ | |||||
/* | |||||
/* | |||||
This file includes the entire juce source tree via the amalgamated file. | This file includes the entire juce source tree via the amalgamated file. | ||||
You could add the amalgamated file directly to your project, but doing it | You could add the amalgamated file directly to your project, but doing it | ||||
like this allows you to put your app's config settings in the | |||||
juce_AppConfig.h file and have them applied to both the juce headers and | |||||
like this allows you to put your app's config settings in the | |||||
juce_AppConfig.h file and have them applied to both the juce headers and | |||||
the source code. | the source code. | ||||
*/ | */ | ||||
@@ -911,4 +911,3 @@ static const unsigned char temp4[] = {137,80,78,71,13,10,26,10,0,0,0,13,73,72,68 | |||||
0,98,28,9,155,95,0,2,104,68,236,11,1,8,160,17,225,73,128,0,3,0,120,52,172,151,198,78,252,63,0,0,0,0,73,69,78,68,174,66, | 0,98,28,9,155,95,0,2,104,68,236,11,1,8,160,17,225,73,128,0,3,0,120,52,172,151,198,78,252,63,0,0,0,0,73,69,78,68,174,66, | ||||
96,130,0,0}; | 96,130,0,0}; | ||||
const char* BinaryData::prefs_misc_png = (const char*) temp4; | const char* BinaryData::prefs_misc_png = (const char*) temp4; | ||||
@@ -30,7 +30,7 @@ | |||||
*/ | */ | ||||
/* | /* | ||||
This file contains settings that you might want to explicitly apply to | |||||
This file contains settings that you might want to explicitly apply to | |||||
the your build. | the your build. | ||||
Most of these are turned on or off by default, but you can override | Most of these are turned on or off by default, but you can override | ||||
@@ -1,10 +1,10 @@ | |||||
/* | |||||
/* | |||||
This file includes the entire juce source tree via the amalgamated file. | This file includes the entire juce source tree via the amalgamated file. | ||||
You could add the amalgamated file directly to your project, but doing it | You could add the amalgamated file directly to your project, but doing it | ||||
like this allows you to put your app's config settings in the | |||||
juce_AppConfig.h file and have them applied to both the juce headers and | |||||
like this allows you to put your app's config settings in the | |||||
juce_AppConfig.h file and have them applied to both the juce headers and | |||||
the source code. | the source code. | ||||
*/ | */ | ||||
@@ -362,7 +362,7 @@ void positionToCode (const RelativePositionedRectangle& position, | |||||
positionToCode (ComponentTypeHandler::getComponentPosition (relCompW), layout, wrx, wry, wrw, wrh); | positionToCode (ComponentTypeHandler::getComponentPosition (relCompW), layout, wrx, wry, wrw, wrh); | ||||
String hrx, hry, hrw, hrh; | String hrx, hry, hrw, hrh; | ||||
Component* const relCompH = (layout != 0 && position.rect.getHeightMode() != PositionedRectangle::absoluteSize) | |||||
Component* const relCompH = (layout != 0 && position.rect.getHeightMode() != PositionedRectangle::absoluteSize) | |||||
? layout->findComponentWithId (position.relativeToH) : 0; | ? layout->findComponentWithId (position.relativeToH) : 0; | ||||
if (relCompH != 0) | if (relCompH != 0) | ||||
positionToCode (ComponentTypeHandler::getComponentPosition (relCompH), layout, hrx, hry, hrw, hrh); | positionToCode (ComponentTypeHandler::getComponentPosition (relCompH), layout, hrx, hry, hrw, hrh); | ||||
@@ -32,7 +32,7 @@ | |||||
/* | /* | ||||
This monolithic file contains the entire Juce source tree! | This monolithic file contains the entire Juce source tree! | ||||
To build an app which uses Juce, all you need to do is to add this | |||||
To build an app which uses Juce, all you need to do is to add this | |||||
file to your project, and include juce.h in your own cpp files. | file to your project, and include juce.h in your own cpp files. | ||||
*/ | */ | ||||
@@ -343,7 +343,7 @@ | |||||
#endif | #endif | ||||
//============================================================================== | //============================================================================== | ||||
// some files include lots of library code, so leave them to the end to avoid cluttering | |||||
// some files include lots of library code, so leave them to the end to avoid cluttering | |||||
// up the build for the clean files. | // up the build for the clean files. | ||||
#include "juce_core/io/streams/juce_GZIPCompressorOutputStream.cpp" | #include "juce_core/io/streams/juce_GZIPCompressorOutputStream.cpp" | ||||
#include "juce_core/io/streams/juce_GZIPDecompressorInputStream.cpp" | #include "juce_core/io/streams/juce_GZIPDecompressorInputStream.cpp" | ||||
@@ -29,11 +29,10 @@ | |||||
============================================================================== | ============================================================================== | ||||
*/ | */ | ||||
/* | /* | ||||
============================================================================== | ============================================================================== | ||||
This header contains the entire Juce source tree, and can be #included in | |||||
This header contains the entire Juce source tree, and can be #included in | |||||
all your source files. | all your source files. | ||||
As well as including this in your files, you should also add juce_inline.cpp | As well as including this in your files, you should also add juce_inline.cpp | ||||
@@ -43,11 +42,11 @@ | |||||
============================================================================== | ============================================================================== | ||||
*/ | */ | ||||
#ifndef __ALL_JUCE_HEADERS_H__ | |||||
#define __ALL_JUCE_HEADERS_H__ | |||||
#ifndef __JUCE_AMALGAMATED_TEMPLATE_JUCEHEADER__ | |||||
#define __JUCE_AMALGAMATED_TEMPLATE_JUCEHEADER__ | |||||
#define DONT_AUTOLINK_TO_JUCE_LIBRARY 1 | #define DONT_AUTOLINK_TO_JUCE_LIBRARY 1 | ||||
#include "../juce.h" | #include "../juce.h" | ||||
#endif | |||||
#endif // __JUCE_AMALGAMATED_TEMPLATE_JUCEHEADER__ |
@@ -97,7 +97,7 @@ public: | |||||
return; | return; | ||||
#elif JUCE_MAC | #elif JUCE_MAC | ||||
EnterMoviesOnThread (0); | EnterMoviesOnThread (0); | ||||
#endif | |||||
#endif | |||||
if (EnterMovies() != noErr) | if (EnterMovies() != noErr) | ||||
return; | return; | ||||
@@ -43,7 +43,7 @@ AudioSourcePlayer::AudioSourcePlayer() | |||||
sampleRate (0), | sampleRate (0), | ||||
bufferSize (0), | bufferSize (0), | ||||
tempBuffer (2, 8), | tempBuffer (2, 8), | ||||
lastGain (1.0f), | |||||
lastGain (1.0f), | |||||
gain (1.0f) | gain (1.0f) | ||||
{ | { | ||||
} | } | ||||
@@ -458,7 +458,7 @@ void AudioDeviceManager::updateXml() | |||||
for (int i = 0; i < midiInsFromXml.size(); ++i) | for (int i = 0; i < midiInsFromXml.size(); ++i) | ||||
{ | { | ||||
if (! availableMidiDevices.contains (midiInsFromXml[i], true)) | |||||
if (! availableMidiDevices.contains (midiInsFromXml[i], true)) | |||||
{ | { | ||||
XmlElement* const m = new XmlElement (T("MIDIINPUT")); | XmlElement* const m = new XmlElement (T("MIDIINPUT")); | ||||
m->setAttribute (T("name"), midiInsFromXml[i]); | m->setAttribute (T("name"), midiInsFromXml[i]); | ||||
@@ -68,21 +68,21 @@ public: | |||||
@param inputChannelData a set of arrays containing the audio data for each | @param inputChannelData a set of arrays containing the audio data for each | ||||
incoming channel - this data is valid until the function | incoming channel - this data is valid until the function | ||||
returns. There will be one channel of data for each input | |||||
returns. There will be one channel of data for each input | |||||
channel that was enabled when the audio device was opened | channel that was enabled when the audio device was opened | ||||
(see AudioIODevice::open()) | (see AudioIODevice::open()) | ||||
@param numInputChannels the number of pointers to channel data in the | |||||
@param numInputChannels the number of pointers to channel data in the | |||||
inputChannelData array. | inputChannelData array. | ||||
@param outputChannelData a set of arrays which need to be filled with the data | @param outputChannelData a set of arrays which need to be filled with the data | ||||
that should be sent to each outgoing channel of the device. | that should be sent to each outgoing channel of the device. | ||||
There will be one channel of data for each output channel | There will be one channel of data for each output channel | ||||
that was enabled when the audio device was opened (see | |||||
that was enabled when the audio device was opened (see | |||||
AudioIODevice::open()) | AudioIODevice::open()) | ||||
The initial contents of the array is undefined, so the | The initial contents of the array is undefined, so the | ||||
callback function must fill all the channels with zeros if | callback function must fill all the channels with zeros if | ||||
its output is silence. Failing to do this could cause quite | its output is silence. Failing to do this could cause quite | ||||
an unpleasant noise! | an unpleasant noise! | ||||
@param numOutputChannels the number of pointers to channel data in the | |||||
@param numOutputChannels the number of pointers to channel data in the | |||||
outputChannelData array. | outputChannelData array. | ||||
@param numSamples the number of samples in each channel of the input and | @param numSamples the number of samples in each channel of the input and | ||||
output arrays. The number of samples will depend on the | output arrays. The number of samples will depend on the | ||||
@@ -1,442 +1,442 @@ | |||||
/* | |||||
============================================================================== | |||||
This file is part of the JUCE library - "Jules' Utility Class Extensions" | |||||
Copyright 2004-7 by Raw Material Software ltd. | |||||
------------------------------------------------------------------------------ | |||||
JUCE can be redistributed and/or modified under the terms of the | |||||
GNU General Public License, as published by the Free Software Foundation; | |||||
either version 2 of the License, or (at your option) any later version. | |||||
JUCE is distributed in the hope that it will be useful, | |||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
GNU General Public License for more details. | |||||
You should have received a copy of the GNU General Public License | |||||
along with JUCE; if not, visit www.gnu.org/licenses or write to the | |||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330, | |||||
Boston, MA 02111-1307 USA | |||||
------------------------------------------------------------------------------ | |||||
If you'd like to release a closed-source product which uses JUCE, commercial | |||||
licenses are also available: visit www.rawmaterialsoftware.com/juce for | |||||
more information. | |||||
============================================================================== | |||||
*/ | |||||
#ifndef __JUCE_AUDIOPROCESSORGRAPH_JUCEHEADER__ | |||||
#define __JUCE_AUDIOPROCESSORGRAPH_JUCEHEADER__ | |||||
#include "juce_AudioProcessor.h" | |||||
#include "../plugins/juce_AudioPluginFormatManager.h" | |||||
#include "../plugins/juce_KnownPluginList.h" | |||||
#include "../../../juce_core/containers/juce_ReferenceCountedArray.h" | |||||
//============================================================================== | |||||
/** | |||||
A type of AudioProcessor which plays back a graph of other AudioProcessors. | |||||
Use one of these objects if you want to wire-up a set of AudioProcessors | |||||
and play back the result. | |||||
Processors can be added to the graph as "nodes" using addNode(), and once | |||||
added, you can connect any of their input or output channels to other | |||||
nodes using addConnection(). | |||||
To play back a graph through an audio device, you might want to use an | |||||
AudioProcessorPlayer object. | |||||
*/ | |||||
class JUCE_API AudioProcessorGraph : public AudioProcessor, | |||||
public AsyncUpdater | |||||
{ | |||||
public: | |||||
//============================================================================== | |||||
/** Creates an empty graph. | |||||
*/ | |||||
AudioProcessorGraph(); | |||||
/** Destructor. | |||||
Any processor objects that have been added to the graph will also be deleted. | |||||
*/ | |||||
~AudioProcessorGraph(); | |||||
//============================================================================== | |||||
/** Represents one of the nodes, or processors, in an AudioProcessorGraph. | |||||
To create a node, call AudioProcessorGraph::addNode(). | |||||
*/ | |||||
class Node : public ReferenceCountedObject | |||||
{ | |||||
public: | |||||
/** Destructor. | |||||
*/ | |||||
~Node(); | |||||
//============================================================================== | |||||
/** The ID number assigned to this node. | |||||
This is assigned by the graph that owns it, and can't be changed. | |||||
*/ | |||||
const uint32 id; | |||||
/** The actual processor object that this node represents. | |||||
*/ | |||||
AudioProcessor* const processor; | |||||
/** A set of user-definable properties that are associated with this node. | |||||
This can be used to attach values to the node for whatever purpose seems | |||||
useful. For example, you might store an x and y position if your application | |||||
is displaying the nodes on-screen. | |||||
*/ | |||||
PropertySet properties; | |||||
//============================================================================== | |||||
/** A convenient typedef for referring to a pointer to a node object. | |||||
*/ | |||||
typedef ReferenceCountedObjectPtr <Node> Ptr; | |||||
//============================================================================== | |||||
juce_UseDebuggingNewOperator | |||||
private: | |||||
friend class AudioProcessorGraph; | |||||
bool isPrepared; | |||||
Node (const uint32 id, AudioProcessor* const processor) throw(); | |||||
void prepare (const double sampleRate, const int blockSize, AudioProcessorGraph* const graph); | |||||
void unprepare(); | |||||
Node (const Node&); | |||||
const Node& operator= (const Node&); | |||||
}; | |||||
//============================================================================== | |||||
/** Represents a connection between two channels of two nodes in an AudioProcessorGraph. | |||||
To create a connection, use AudioProcessorGraph::addConnection(). | |||||
*/ | |||||
struct Connection | |||||
{ | |||||
public: | |||||
//============================================================================== | |||||
/** The ID number of the node which is the input source for this connection. | |||||
@see AudioProcessorGraph::getNodeForId | |||||
*/ | |||||
uint32 sourceNodeId; | |||||
/** The index of the output channel of the source node from which this | |||||
connection takes its data. | |||||
If this value is the special number AudioProcessorGraph::midiChannelIndex, then | |||||
it is referring to the source node's midi output. Otherwise, it is the zero-based | |||||
index of an audio output channel in the source node. | |||||
*/ | |||||
int sourceChannelIndex; | |||||
/** The ID number of the node which is the destination for this connection. | |||||
@see AudioProcessorGraph::getNodeForId | |||||
*/ | |||||
uint32 destNodeId; | |||||
/** The index of the input channel of the destination node to which this | |||||
connection delivers its data. | |||||
If this value is the special number AudioProcessorGraph::midiChannelIndex, then | |||||
it is referring to the destination node's midi input. Otherwise, it is the zero-based | |||||
index of an audio input channel in the destination node. | |||||
*/ | |||||
int destChannelIndex; | |||||
//============================================================================== | |||||
juce_UseDebuggingNewOperator | |||||
private: | |||||
}; | |||||
//============================================================================== | |||||
/** Deletes all nodes and connections from this graph. | |||||
Any processor objects in the graph will be deleted. | |||||
*/ | |||||
void clear(); | |||||
/** Returns the number of nodes in the graph. */ | |||||
int getNumNodes() const throw() { return nodes.size(); } | |||||
/** Returns a pointer to one of the nodes in the graph. | |||||
This will return 0 if the index is out of range. | |||||
@see getNodeForId | |||||
*/ | |||||
Node* getNode (const int index) const throw() { return nodes [index]; } | |||||
/** Searches the graph for a node with the given ID number and returns it. | |||||
If no such node was found, this returns 0. | |||||
@see getNode | |||||
*/ | |||||
Node* getNodeForId (const uint32 nodeId) const throw(); | |||||
/** Adds a node to the graph. | |||||
This creates a new node in the graph, for the specified processor. Once you have | |||||
added a processor to the graph, the graph owns it and will delete it later when | |||||
it is no longer needed. | |||||
The optional nodeId parameter lets you specify an ID to use for the node, but | |||||
if the value is already in use, this new node will overwrite the old one. | |||||
If this succeeds, it returns a pointer to the newly-created node. | |||||
*/ | |||||
Node* addNode (AudioProcessor* const newProcessor, | |||||
uint32 nodeId = 0); | |||||
/** Deletes a node within the graph which has the specified ID. | |||||
This will also delete any connections that are attached to this node. | |||||
*/ | |||||
bool removeNode (const uint32 nodeId); | |||||
//============================================================================== | |||||
/** Returns the number of connections in the graph. */ | |||||
int getNumConnections() const throw() { return connections.size(); } | |||||
/** Returns a pointer to one of the connections in the graph. */ | |||||
const Connection* getConnection (const int index) const throw() { return connections [index]; } | |||||
/** Searches for a connection between some specified channels. | |||||
If no such connection is found, this returns 0. | |||||
*/ | |||||
const Connection* getConnectionBetween (const uint32 sourceNodeId, | |||||
const int sourceChannelIndex, | |||||
const uint32 destNodeId, | |||||
const int destChannelIndex) const throw(); | |||||
/** Returns true if there is a connection between any of the channels of | |||||
two specified nodes. | |||||
*/ | |||||
bool isConnected (const uint32 possibleSourceNodeId, | |||||
const uint32 possibleDestNodeId) const throw(); | |||||
/** Returns true if it would be legal to connect the specified points. | |||||
*/ | |||||
bool canConnect (const uint32 sourceNodeId, const int sourceChannelIndex, | |||||
const uint32 destNodeId, const int destChannelIndex) const throw(); | |||||
/** Attempts to connect two specified channels of two nodes. | |||||
If this isn't allowed (e.g. because you're trying to connect a midi channel | |||||
to an audio one or other such nonsense), then it'll return false. | |||||
*/ | |||||
bool addConnection (const uint32 sourceNodeId, const int sourceChannelIndex, | |||||
const uint32 destNodeId, const int destChannelIndex); | |||||
/** Deletes the connection with the specified index. | |||||
Returns true if a connection was actually deleted. | |||||
*/ | |||||
void removeConnection (const int index); | |||||
/** Deletes any connection between two specified points. | |||||
Returns true if a connection was actually deleted. | |||||
*/ | |||||
bool removeConnection (const uint32 sourceNodeId, const int sourceChannelIndex, | |||||
const uint32 destNodeId, const int destChannelIndex); | |||||
/** Removes all connections from the specified node. | |||||
*/ | |||||
bool disconnectNode (const uint32 nodeId); | |||||
/** Performs a sanity checks of all the connections. | |||||
This might be useful if some of the processors are doing things like changing | |||||
their channel counts, which could render some connections obsolete. | |||||
*/ | |||||
bool removeIllegalConnections(); | |||||
//============================================================================== | |||||
/** A special number that represents the midi channel of a node. | |||||
This is used as a channel index value if you want to refer to the midi input | |||||
or output instead of an audio channel. | |||||
*/ | |||||
static const int midiChannelIndex; | |||||
//============================================================================== | |||||
/** A special type of AudioProcessor that can live inside an AudioProcessorGraph | |||||
in order to use the audio that comes into and out of the graph itself. | |||||
If you create an AudioGraphIOProcessor in "input" mode, it will act as a | |||||
node in the graph which delivers the audio that is coming into the parent | |||||
graph. This allows you to stream the data to other nodes and process the | |||||
incoming audio. | |||||
Likewise, one of these in "output" mode can be sent data which it will add to | |||||
the sum of data being sent to the graph's output. | |||||
@see AudioProcessorGraph | |||||
*/ | |||||
class AudioGraphIOProcessor : public AudioPluginInstance | |||||
{ | |||||
public: | |||||
/** Specifies the mode in which this processor will operate. | |||||
*/ | |||||
enum IODeviceType | |||||
{ | |||||
audioInputNode, /**< In this mode, the processor has output channels | |||||
representing all the audio input channels that are | |||||
coming into its parent audio graph. */ | |||||
audioOutputNode, /**< In this mode, the processor has input channels | |||||
representing all the audio output channels that are | |||||
going out of its parent audio graph. */ | |||||
midiInputNode, /**< In this mode, the processor has a midi output which | |||||
delivers the same midi data that is arriving at its | |||||
parent graph. */ | |||||
midiOutputNode /**< In this mode, the processor has a midi input and | |||||
any data sent to it will be passed out of the parent | |||||
graph. */ | |||||
}; | |||||
//============================================================================== | |||||
/** Returns the mode of this processor. */ | |||||
IODeviceType getType() const throw() { return type; } | |||||
/** Returns the parent graph to which this processor belongs, or 0 if it | |||||
hasn't yet been added to one. */ | |||||
AudioProcessorGraph* getParentGraph() const throw() { return graph; } | |||||
/** True if this is an audio or midi input. */ | |||||
bool isInput() const throw(); | |||||
/** True if this is an audio or midi output. */ | |||||
bool isOutput() const throw(); | |||||
//============================================================================== | |||||
AudioGraphIOProcessor (const IODeviceType type); | |||||
~AudioGraphIOProcessor(); | |||||
const String getName() const; | |||||
void fillInPluginDescription (PluginDescription& d) const; | |||||
void prepareToPlay (double sampleRate, int estimatedSamplesPerBlock); | |||||
void releaseResources(); | |||||
void processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages); | |||||
const String getInputChannelName (const int channelIndex) const; | |||||
const String getOutputChannelName (const int channelIndex) const; | |||||
bool isInputChannelStereoPair (int index) const; | |||||
bool isOutputChannelStereoPair (int index) const; | |||||
bool acceptsMidi() const; | |||||
bool producesMidi() const; | |||||
AudioProcessorEditor* createEditor(); | |||||
int getNumParameters(); | |||||
const String getParameterName (int); | |||||
float getParameter (int); | |||||
const String getParameterText (int); | |||||
void setParameter (int, float); | |||||
int getNumPrograms(); | |||||
int getCurrentProgram(); | |||||
void setCurrentProgram (int); | |||||
const String getProgramName (int); | |||||
void changeProgramName (int, const String&); | |||||
void getStateInformation (JUCE_NAMESPACE::MemoryBlock& destData); | |||||
void setStateInformation (const void* data, int sizeInBytes); | |||||
/** @internal */ | |||||
void setParentGraph (AudioProcessorGraph* const graph) throw(); | |||||
juce_UseDebuggingNewOperator | |||||
private: | |||||
const IODeviceType type; | |||||
AudioProcessorGraph* graph; | |||||
AudioGraphIOProcessor (const AudioGraphIOProcessor&); | |||||
const AudioGraphIOProcessor& operator= (const AudioGraphIOProcessor&); | |||||
}; | |||||
//============================================================================== | |||||
// AudioProcessor methods: | |||||
const String getName() const; | |||||
void prepareToPlay (double sampleRate, int estimatedSamplesPerBlock); | |||||
void releaseResources(); | |||||
void processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages); | |||||
const String getInputChannelName (const int channelIndex) const; | |||||
const String getOutputChannelName (const int channelIndex) const; | |||||
bool isInputChannelStereoPair (int index) const; | |||||
bool isOutputChannelStereoPair (int index) const; | |||||
bool acceptsMidi() const; | |||||
bool producesMidi() const; | |||||
AudioProcessorEditor* createEditor() { return 0; } | |||||
int getNumParameters() { return 0; } | |||||
const String getParameterName (int) { return String::empty; } | |||||
float getParameter (int) { return 0; } | |||||
const String getParameterText (int) { return String::empty; } | |||||
void setParameter (int, float) { } | |||||
int getNumPrograms() { return 0; } | |||||
int getCurrentProgram() { return 0; } | |||||
void setCurrentProgram (int) { } | |||||
const String getProgramName (int) { return String::empty; } | |||||
void changeProgramName (int, const String&) { } | |||||
void getStateInformation (JUCE_NAMESPACE::MemoryBlock& destData); | |||||
void setStateInformation (const void* data, int sizeInBytes); | |||||
/** @internal */ | |||||
void handleAsyncUpdate(); | |||||
//============================================================================== | |||||
juce_UseDebuggingNewOperator | |||||
private: | |||||
ReferenceCountedArray <Node> nodes; | |||||
OwnedArray <Connection> connections; | |||||
int lastNodeId; | |||||
AudioSampleBuffer renderingBuffers; | |||||
OwnedArray <MidiBuffer> midiBuffers; | |||||
CriticalSection renderLock; | |||||
VoidArray renderingOps; | |||||
friend class AudioGraphIOProcessor; | |||||
AudioSampleBuffer* currentAudioInputBuffer; | |||||
AudioSampleBuffer currentAudioOutputBuffer; | |||||
MidiBuffer* currentMidiInputBuffer; | |||||
MidiBuffer currentMidiOutputBuffer; | |||||
void clearRenderingSequence(); | |||||
void buildRenderingSequence(); | |||||
bool isAnInputTo (const uint32 possibleInputId, | |||||
const uint32 possibleDestinationId, | |||||
const int recursionCheck) const throw(); | |||||
AudioProcessorGraph (const AudioProcessorGraph&); | |||||
const AudioProcessorGraph& operator= (const AudioProcessorGraph&); | |||||
}; | |||||
#endif // __JUCE_AUDIOPROCESSORGRAPH_JUCEHEADER__ | |||||
/* | |||||
============================================================================== | |||||
This file is part of the JUCE library - "Jules' Utility Class Extensions" | |||||
Copyright 2004-7 by Raw Material Software ltd. | |||||
------------------------------------------------------------------------------ | |||||
JUCE can be redistributed and/or modified under the terms of the | |||||
GNU General Public License, as published by the Free Software Foundation; | |||||
either version 2 of the License, or (at your option) any later version. | |||||
JUCE is distributed in the hope that it will be useful, | |||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
GNU General Public License for more details. | |||||
You should have received a copy of the GNU General Public License | |||||
along with JUCE; if not, visit www.gnu.org/licenses or write to the | |||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330, | |||||
Boston, MA 02111-1307 USA | |||||
------------------------------------------------------------------------------ | |||||
If you'd like to release a closed-source product which uses JUCE, commercial | |||||
licenses are also available: visit www.rawmaterialsoftware.com/juce for | |||||
more information. | |||||
============================================================================== | |||||
*/ | |||||
#ifndef __JUCE_AUDIOPROCESSORGRAPH_JUCEHEADER__ | |||||
#define __JUCE_AUDIOPROCESSORGRAPH_JUCEHEADER__ | |||||
#include "juce_AudioProcessor.h" | |||||
#include "../plugins/juce_AudioPluginFormatManager.h" | |||||
#include "../plugins/juce_KnownPluginList.h" | |||||
#include "../../../juce_core/containers/juce_ReferenceCountedArray.h" | |||||
//============================================================================== | |||||
/** | |||||
A type of AudioProcessor which plays back a graph of other AudioProcessors. | |||||
Use one of these objects if you want to wire-up a set of AudioProcessors | |||||
and play back the result. | |||||
Processors can be added to the graph as "nodes" using addNode(), and once | |||||
added, you can connect any of their input or output channels to other | |||||
nodes using addConnection(). | |||||
To play back a graph through an audio device, you might want to use an | |||||
AudioProcessorPlayer object. | |||||
*/ | |||||
class JUCE_API AudioProcessorGraph : public AudioProcessor, | |||||
public AsyncUpdater | |||||
{ | |||||
public: | |||||
//============================================================================== | |||||
/** Creates an empty graph. | |||||
*/ | |||||
AudioProcessorGraph(); | |||||
/** Destructor. | |||||
Any processor objects that have been added to the graph will also be deleted. | |||||
*/ | |||||
~AudioProcessorGraph(); | |||||
//============================================================================== | |||||
/** Represents one of the nodes, or processors, in an AudioProcessorGraph. | |||||
To create a node, call AudioProcessorGraph::addNode(). | |||||
*/ | |||||
class Node : public ReferenceCountedObject | |||||
{ | |||||
public: | |||||
/** Destructor. | |||||
*/ | |||||
~Node(); | |||||
//============================================================================== | |||||
/** The ID number assigned to this node. | |||||
This is assigned by the graph that owns it, and can't be changed. | |||||
*/ | |||||
const uint32 id; | |||||
/** The actual processor object that this node represents. | |||||
*/ | |||||
AudioProcessor* const processor; | |||||
/** A set of user-definable properties that are associated with this node. | |||||
This can be used to attach values to the node for whatever purpose seems | |||||
useful. For example, you might store an x and y position if your application | |||||
is displaying the nodes on-screen. | |||||
*/ | |||||
PropertySet properties; | |||||
//============================================================================== | |||||
/** A convenient typedef for referring to a pointer to a node object. | |||||
*/ | |||||
typedef ReferenceCountedObjectPtr <Node> Ptr; | |||||
//============================================================================== | |||||
juce_UseDebuggingNewOperator | |||||
private: | |||||
friend class AudioProcessorGraph; | |||||
bool isPrepared; | |||||
Node (const uint32 id, AudioProcessor* const processor) throw(); | |||||
void prepare (const double sampleRate, const int blockSize, AudioProcessorGraph* const graph); | |||||
void unprepare(); | |||||
Node (const Node&); | |||||
const Node& operator= (const Node&); | |||||
}; | |||||
//============================================================================== | |||||
/** Represents a connection between two channels of two nodes in an AudioProcessorGraph. | |||||
To create a connection, use AudioProcessorGraph::addConnection(). | |||||
*/ | |||||
struct Connection | |||||
{ | |||||
public: | |||||
//============================================================================== | |||||
/** The ID number of the node which is the input source for this connection. | |||||
@see AudioProcessorGraph::getNodeForId | |||||
*/ | |||||
uint32 sourceNodeId; | |||||
/** The index of the output channel of the source node from which this | |||||
connection takes its data. | |||||
If this value is the special number AudioProcessorGraph::midiChannelIndex, then | |||||
it is referring to the source node's midi output. Otherwise, it is the zero-based | |||||
index of an audio output channel in the source node. | |||||
*/ | |||||
int sourceChannelIndex; | |||||
/** The ID number of the node which is the destination for this connection. | |||||
@see AudioProcessorGraph::getNodeForId | |||||
*/ | |||||
uint32 destNodeId; | |||||
/** The index of the input channel of the destination node to which this | |||||
connection delivers its data. | |||||
If this value is the special number AudioProcessorGraph::midiChannelIndex, then | |||||
it is referring to the destination node's midi input. Otherwise, it is the zero-based | |||||
index of an audio input channel in the destination node. | |||||
*/ | |||||
int destChannelIndex; | |||||
//============================================================================== | |||||
juce_UseDebuggingNewOperator | |||||
private: | |||||
}; | |||||
//============================================================================== | |||||
/** Deletes all nodes and connections from this graph. | |||||
Any processor objects in the graph will be deleted. | |||||
*/ | |||||
void clear(); | |||||
/** Returns the number of nodes in the graph. */ | |||||
int getNumNodes() const throw() { return nodes.size(); } | |||||
/** Returns a pointer to one of the nodes in the graph. | |||||
This will return 0 if the index is out of range. | |||||
@see getNodeForId | |||||
*/ | |||||
Node* getNode (const int index) const throw() { return nodes [index]; } | |||||
/** Searches the graph for a node with the given ID number and returns it. | |||||
If no such node was found, this returns 0. | |||||
@see getNode | |||||
*/ | |||||
Node* getNodeForId (const uint32 nodeId) const throw(); | |||||
/** Adds a node to the graph. | |||||
This creates a new node in the graph, for the specified processor. Once you have | |||||
added a processor to the graph, the graph owns it and will delete it later when | |||||
it is no longer needed. | |||||
The optional nodeId parameter lets you specify an ID to use for the node, but | |||||
if the value is already in use, this new node will overwrite the old one. | |||||
If this succeeds, it returns a pointer to the newly-created node. | |||||
*/ | |||||
Node* addNode (AudioProcessor* const newProcessor, | |||||
uint32 nodeId = 0); | |||||
/** Deletes a node within the graph which has the specified ID. | |||||
This will also delete any connections that are attached to this node. | |||||
*/ | |||||
bool removeNode (const uint32 nodeId); | |||||
//============================================================================== | |||||
/** Returns the number of connections in the graph. */ | |||||
int getNumConnections() const throw() { return connections.size(); } | |||||
/** Returns a pointer to one of the connections in the graph. */ | |||||
const Connection* getConnection (const int index) const throw() { return connections [index]; } | |||||
/** Searches for a connection between some specified channels. | |||||
If no such connection is found, this returns 0. | |||||
*/ | |||||
const Connection* getConnectionBetween (const uint32 sourceNodeId, | |||||
const int sourceChannelIndex, | |||||
const uint32 destNodeId, | |||||
const int destChannelIndex) const throw(); | |||||
/** Returns true if there is a connection between any of the channels of | |||||
two specified nodes. | |||||
*/ | |||||
bool isConnected (const uint32 possibleSourceNodeId, | |||||
const uint32 possibleDestNodeId) const throw(); | |||||
/** Returns true if it would be legal to connect the specified points. | |||||
*/ | |||||
bool canConnect (const uint32 sourceNodeId, const int sourceChannelIndex, | |||||
const uint32 destNodeId, const int destChannelIndex) const throw(); | |||||
/** Attempts to connect two specified channels of two nodes. | |||||
If this isn't allowed (e.g. because you're trying to connect a midi channel | |||||
to an audio one or other such nonsense), then it'll return false. | |||||
*/ | |||||
bool addConnection (const uint32 sourceNodeId, const int sourceChannelIndex, | |||||
const uint32 destNodeId, const int destChannelIndex); | |||||
/** Deletes the connection with the specified index. | |||||
Returns true if a connection was actually deleted. | |||||
*/ | |||||
void removeConnection (const int index); | |||||
/** Deletes any connection between two specified points. | |||||
Returns true if a connection was actually deleted. | |||||
*/ | |||||
bool removeConnection (const uint32 sourceNodeId, const int sourceChannelIndex, | |||||
const uint32 destNodeId, const int destChannelIndex); | |||||
/** Removes all connections from the specified node. | |||||
*/ | |||||
bool disconnectNode (const uint32 nodeId); | |||||
/** Performs a sanity checks of all the connections. | |||||
This might be useful if some of the processors are doing things like changing | |||||
their channel counts, which could render some connections obsolete. | |||||
*/ | |||||
bool removeIllegalConnections(); | |||||
//============================================================================== | |||||
/** A special number that represents the midi channel of a node. | |||||
This is used as a channel index value if you want to refer to the midi input | |||||
or output instead of an audio channel. | |||||
*/ | |||||
static const int midiChannelIndex; | |||||
//============================================================================== | |||||
/** A special type of AudioProcessor that can live inside an AudioProcessorGraph | |||||
in order to use the audio that comes into and out of the graph itself. | |||||
If you create an AudioGraphIOProcessor in "input" mode, it will act as a | |||||
node in the graph which delivers the audio that is coming into the parent | |||||
graph. This allows you to stream the data to other nodes and process the | |||||
incoming audio. | |||||
Likewise, one of these in "output" mode can be sent data which it will add to | |||||
the sum of data being sent to the graph's output. | |||||
@see AudioProcessorGraph | |||||
*/ | |||||
class AudioGraphIOProcessor : public AudioPluginInstance | |||||
{ | |||||
public: | |||||
/** Specifies the mode in which this processor will operate. | |||||
*/ | |||||
enum IODeviceType | |||||
{ | |||||
audioInputNode, /**< In this mode, the processor has output channels | |||||
representing all the audio input channels that are | |||||
coming into its parent audio graph. */ | |||||
audioOutputNode, /**< In this mode, the processor has input channels | |||||
representing all the audio output channels that are | |||||
going out of its parent audio graph. */ | |||||
midiInputNode, /**< In this mode, the processor has a midi output which | |||||
delivers the same midi data that is arriving at its | |||||
parent graph. */ | |||||
midiOutputNode /**< In this mode, the processor has a midi input and | |||||
any data sent to it will be passed out of the parent | |||||
graph. */ | |||||
}; | |||||
//============================================================================== | |||||
/** Returns the mode of this processor. */ | |||||
IODeviceType getType() const throw() { return type; } | |||||
/** Returns the parent graph to which this processor belongs, or 0 if it | |||||
hasn't yet been added to one. */ | |||||
AudioProcessorGraph* getParentGraph() const throw() { return graph; } | |||||
/** True if this is an audio or midi input. */ | |||||
bool isInput() const throw(); | |||||
/** True if this is an audio or midi output. */ | |||||
bool isOutput() const throw(); | |||||
//============================================================================== | |||||
AudioGraphIOProcessor (const IODeviceType type); | |||||
~AudioGraphIOProcessor(); | |||||
const String getName() const; | |||||
void fillInPluginDescription (PluginDescription& d) const; | |||||
void prepareToPlay (double sampleRate, int estimatedSamplesPerBlock); | |||||
void releaseResources(); | |||||
void processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages); | |||||
const String getInputChannelName (const int channelIndex) const; | |||||
const String getOutputChannelName (const int channelIndex) const; | |||||
bool isInputChannelStereoPair (int index) const; | |||||
bool isOutputChannelStereoPair (int index) const; | |||||
bool acceptsMidi() const; | |||||
bool producesMidi() const; | |||||
AudioProcessorEditor* createEditor(); | |||||
int getNumParameters(); | |||||
const String getParameterName (int); | |||||
float getParameter (int); | |||||
const String getParameterText (int); | |||||
void setParameter (int, float); | |||||
int getNumPrograms(); | |||||
int getCurrentProgram(); | |||||
void setCurrentProgram (int); | |||||
const String getProgramName (int); | |||||
void changeProgramName (int, const String&); | |||||
void getStateInformation (JUCE_NAMESPACE::MemoryBlock& destData); | |||||
void setStateInformation (const void* data, int sizeInBytes); | |||||
/** @internal */ | |||||
void setParentGraph (AudioProcessorGraph* const graph) throw(); | |||||
juce_UseDebuggingNewOperator | |||||
private: | |||||
const IODeviceType type; | |||||
AudioProcessorGraph* graph; | |||||
AudioGraphIOProcessor (const AudioGraphIOProcessor&); | |||||
const AudioGraphIOProcessor& operator= (const AudioGraphIOProcessor&); | |||||
}; | |||||
//============================================================================== | |||||
// AudioProcessor methods: | |||||
const String getName() const; | |||||
void prepareToPlay (double sampleRate, int estimatedSamplesPerBlock); | |||||
void releaseResources(); | |||||
void processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages); | |||||
const String getInputChannelName (const int channelIndex) const; | |||||
const String getOutputChannelName (const int channelIndex) const; | |||||
bool isInputChannelStereoPair (int index) const; | |||||
bool isOutputChannelStereoPair (int index) const; | |||||
bool acceptsMidi() const; | |||||
bool producesMidi() const; | |||||
AudioProcessorEditor* createEditor() { return 0; } | |||||
int getNumParameters() { return 0; } | |||||
const String getParameterName (int) { return String::empty; } | |||||
float getParameter (int) { return 0; } | |||||
const String getParameterText (int) { return String::empty; } | |||||
void setParameter (int, float) { } | |||||
int getNumPrograms() { return 0; } | |||||
int getCurrentProgram() { return 0; } | |||||
void setCurrentProgram (int) { } | |||||
const String getProgramName (int) { return String::empty; } | |||||
void changeProgramName (int, const String&) { } | |||||
void getStateInformation (JUCE_NAMESPACE::MemoryBlock& destData); | |||||
void setStateInformation (const void* data, int sizeInBytes); | |||||
/** @internal */ | |||||
void handleAsyncUpdate(); | |||||
//============================================================================== | |||||
juce_UseDebuggingNewOperator | |||||
private: | |||||
ReferenceCountedArray <Node> nodes; | |||||
OwnedArray <Connection> connections; | |||||
int lastNodeId; | |||||
AudioSampleBuffer renderingBuffers; | |||||
OwnedArray <MidiBuffer> midiBuffers; | |||||
CriticalSection renderLock; | |||||
VoidArray renderingOps; | |||||
friend class AudioGraphIOProcessor; | |||||
AudioSampleBuffer* currentAudioInputBuffer; | |||||
AudioSampleBuffer currentAudioOutputBuffer; | |||||
MidiBuffer* currentMidiInputBuffer; | |||||
MidiBuffer currentMidiOutputBuffer; | |||||
void clearRenderingSequence(); | |||||
void buildRenderingSequence(); | |||||
bool isAnInputTo (const uint32 possibleInputId, | |||||
const uint32 possibleDestinationId, | |||||
const int recursionCheck) const throw(); | |||||
AudioProcessorGraph (const AudioProcessorGraph&); | |||||
const AudioProcessorGraph& operator= (const AudioProcessorGraph&); | |||||
}; | |||||
#endif // __JUCE_AUDIOPROCESSORGRAPH_JUCEHEADER__ |
@@ -549,7 +549,7 @@ void ComboBox::showPopup() | |||||
else if (item->isHeading) | else if (item->isHeading) | ||||
menu.addSectionHeader (item->name); | menu.addSectionHeader (item->name); | ||||
else | else | ||||
menu.addItem (item->itemId, item->name, | |||||
menu.addItem (item->itemId, item->name, | |||||
item->isEnabled, item->itemId == currentId); | item->isEnabled, item->itemId == currentId); | ||||
} | } | ||||
@@ -37,7 +37,7 @@ BEGIN_JUCE_NAMESPACE | |||||
#include "../../graphics/imaging/juce_ImageCache.h" | #include "../../graphics/imaging/juce_ImageCache.h" | ||||
void* juce_findFileStart (const String& directory, const String& wildCard, String& firstResultFile, | void* juce_findFileStart (const String& directory, const String& wildCard, String& firstResultFile, | ||||
bool* isDirectory, bool* isHidden, int64* fileSize, Time* modTime, | |||||
bool* isDirectory, bool* isHidden, int64* fileSize, Time* modTime, | |||||
Time* creationTime, bool* isReadOnly) throw(); | Time* creationTime, bool* isReadOnly) throw(); | ||||
bool juce_findFileNext (void* handle, String& resultFile, | bool juce_findFileNext (void* handle, String& resultFile, | ||||
bool* isDirectory, bool* isHidden, int64* fileSize, | bool* isDirectory, bool* isHidden, int64* fileSize, | ||||
@@ -82,7 +82,7 @@ public: | |||||
do its own repainting, but only to repaint when the | do its own repainting, but only to repaint when the | ||||
performAnyPendingRepaintsNow() method is called. */ | performAnyPendingRepaintsNow() method is called. */ | ||||
windowIsSemiTransparent = (1 << 31) /**< Not intended for public use - makes a window transparent. */ | windowIsSemiTransparent = (1 << 31) /**< Not intended for public use - makes a window transparent. */ | ||||
}; | }; | ||||
//============================================================================== | //============================================================================== | ||||
@@ -1,344 +1,344 @@ | |||||
/* | |||||
============================================================================== | |||||
This file is part of the JUCE library - "Jules' Utility Class Extensions" | |||||
Copyright 2004-7 by Raw Material Software ltd. | |||||
------------------------------------------------------------------------------ | |||||
JUCE can be redistributed and/or modified under the terms of the | |||||
GNU General Public License, as published by the Free Software Foundation; | |||||
either version 2 of the License, or (at your option) any later version. | |||||
JUCE is distributed in the hope that it will be useful, | |||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
GNU General Public License for more details. | |||||
You should have received a copy of the GNU General Public License | |||||
along with JUCE; if not, visit www.gnu.org/licenses or write to the | |||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330, | |||||
Boston, MA 02111-1307 USA | |||||
------------------------------------------------------------------------------ | |||||
If you'd like to release a closed-source product which uses JUCE, commercial | |||||
licenses are also available: visit www.rawmaterialsoftware.com/juce for | |||||
more information. | |||||
============================================================================== | |||||
*/ | |||||
#include "../../../../../juce_core/basics/juce_StandardHeader.h" | |||||
#ifdef _MSC_VER | |||||
#pragma warning (push) | |||||
#pragma warning (disable: 4390 4611) | |||||
#endif | |||||
namespace zlibNamespace | |||||
{ | |||||
#undef OS_CODE | |||||
#undef fdopen | |||||
#include "../../../../../juce_core/io/streams/zlib/zlib.h" | |||||
#undef OS_CODE | |||||
} | |||||
namespace pnglibNamespace | |||||
{ | |||||
using namespace zlibNamespace; | |||||
using ::malloc; | |||||
using ::free; | |||||
extern "C" | |||||
{ | |||||
using ::abs; | |||||
#define PNG_INTERNAL | |||||
#define NO_DUMMY_DECL | |||||
#define PNG_SETJMP_NOT_SUPPORTED | |||||
#include "pnglib/png.h" | |||||
#include "pnglib/pngconf.h" | |||||
#define PNG_NO_EXTERN | |||||
#include "pnglib/png.c" | |||||
#include "pnglib/pngerror.c" | |||||
#include "pnglib/pngget.c" | |||||
#include "pnglib/pngmem.c" | |||||
#include "pnglib/pngread.c" | |||||
#include "pnglib/pngpread.c" | |||||
#include "pnglib/pngrio.c" | |||||
#include "pnglib/pngrtran.c" | |||||
#include "pnglib/pngrutil.c" | |||||
#include "pnglib/pngset.c" | |||||
#include "pnglib/pngtrans.c" | |||||
#include "pnglib/pngwio.c" | |||||
#include "pnglib/pngwrite.c" | |||||
#include "pnglib/pngwtran.c" | |||||
#include "pnglib/pngwutil.c" | |||||
} | |||||
} | |||||
#ifdef _MSC_VER | |||||
#pragma warning (pop) | |||||
#endif | |||||
BEGIN_JUCE_NAMESPACE | |||||
#include "../juce_Image.h" | |||||
#include "../../../../../juce_core/io/juce_InputStream.h" | |||||
#include "../../../../../juce_core/io/juce_OutputStream.h" | |||||
#include "../../colour/juce_PixelFormats.h" | |||||
using namespace pnglibNamespace; | |||||
using ::malloc; | |||||
using ::free; | |||||
//============================================================================== | |||||
static void pngReadCallback (png_structp pngReadStruct, png_bytep data, png_size_t length) throw() | |||||
{ | |||||
InputStream* const in = (InputStream*) png_get_io_ptr (pngReadStruct); | |||||
in->read (data, (int) length); | |||||
} | |||||
struct PNGErrorStruct {}; | |||||
static void pngErrorCallback (png_structp, png_const_charp) | |||||
{ | |||||
throw PNGErrorStruct(); | |||||
} | |||||
//============================================================================== | |||||
Image* juce_loadPNGImageFromStream (InputStream& in) throw() | |||||
{ | |||||
Image* image = 0; | |||||
png_structp pngReadStruct; | |||||
png_infop pngInfoStruct; | |||||
pngReadStruct = png_create_read_struct (PNG_LIBPNG_VER_STRING, 0, 0, 0); | |||||
if (pngReadStruct != 0) | |||||
{ | |||||
pngInfoStruct = png_create_info_struct (pngReadStruct); | |||||
if (pngInfoStruct == 0) | |||||
{ | |||||
png_destroy_read_struct (&pngReadStruct, 0, 0); | |||||
return 0; | |||||
} | |||||
png_set_error_fn (pngReadStruct, 0, pngErrorCallback, pngErrorCallback); | |||||
// read the header.. | |||||
png_set_read_fn (pngReadStruct, &in, pngReadCallback); | |||||
png_uint_32 width, height; | |||||
int bitDepth, colorType, interlaceType; | |||||
try | |||||
{ | |||||
png_read_info (pngReadStruct, pngInfoStruct); | |||||
png_get_IHDR (pngReadStruct, pngInfoStruct, | |||||
&width, &height, | |||||
&bitDepth, &colorType, | |||||
&interlaceType, 0, 0); | |||||
} | |||||
catch (...) | |||||
{ | |||||
png_destroy_read_struct (&pngReadStruct, 0, 0); | |||||
return 0; | |||||
} | |||||
if (bitDepth == 16) | |||||
png_set_strip_16 (pngReadStruct); | |||||
if (colorType == PNG_COLOR_TYPE_PALETTE) | |||||
png_set_expand (pngReadStruct); | |||||
if (bitDepth < 8) | |||||
png_set_expand (pngReadStruct); | |||||
if (png_get_valid (pngReadStruct, pngInfoStruct, PNG_INFO_tRNS)) | |||||
png_set_expand (pngReadStruct); | |||||
if (colorType == PNG_COLOR_TYPE_GRAY || colorType == PNG_COLOR_TYPE_GRAY_ALPHA) | |||||
png_set_gray_to_rgb (pngReadStruct); | |||||
png_set_add_alpha (pngReadStruct, 0xff, PNG_FILLER_AFTER); | |||||
const bool hasAlphaChan = (colorType & PNG_COLOR_MASK_ALPHA) != 0 | |||||
|| pngInfoStruct->num_trans > 0; | |||||
// Load the image into a temp buffer in the pnglib format.. | |||||
uint8* const tempBuffer = (uint8*) juce_malloc (height * (width << 2)); | |||||
png_bytepp rows = (png_bytepp) juce_malloc (sizeof (png_bytep) * height); | |||||
int y; | |||||
for (y = (int) height; --y >= 0;) | |||||
rows[y] = (png_bytep) (tempBuffer + (width << 2) * y); | |||||
bool crashed = false; | |||||
try | |||||
{ | |||||
png_read_image (pngReadStruct, rows); | |||||
png_read_end (pngReadStruct, pngInfoStruct); | |||||
} | |||||
catch (...) | |||||
{ | |||||
crashed = true; | |||||
} | |||||
juce_free (rows); | |||||
png_destroy_read_struct (&pngReadStruct, &pngInfoStruct, 0); | |||||
if (crashed) | |||||
return 0; | |||||
// now convert the data to a juce image format.. | |||||
image = new Image (hasAlphaChan ? Image::ARGB : Image::RGB, | |||||
width, height, hasAlphaChan); | |||||
int stride, pixelStride; | |||||
uint8* const pixels = image->lockPixelDataReadWrite (0, 0, width, height, stride, pixelStride); | |||||
uint8* srcRow = tempBuffer; | |||||
uint8* destRow = pixels; | |||||
for (y = 0; y < (int) height; ++y) | |||||
{ | |||||
const uint8* src = srcRow; | |||||
srcRow += (width << 2); | |||||
uint8* dest = destRow; | |||||
destRow += stride; | |||||
if (hasAlphaChan) | |||||
{ | |||||
for (int i = width; --i >= 0;) | |||||
{ | |||||
((PixelARGB*) dest)->setARGB (src[3], src[0], src[1], src[2]); | |||||
((PixelARGB*) dest)->premultiply(); | |||||
dest += pixelStride; | |||||
src += 4; | |||||
} | |||||
} | |||||
else | |||||
{ | |||||
for (int i = width; --i >= 0;) | |||||
{ | |||||
((PixelRGB*) dest)->setARGB (0, src[0], src[1], src[2]); | |||||
dest += pixelStride; | |||||
src += 4; | |||||
} | |||||
} | |||||
} | |||||
image->releasePixelDataReadWrite (pixels); | |||||
juce_free (tempBuffer); | |||||
} | |||||
return image; | |||||
} | |||||
//============================================================================== | |||||
static void pngWriteDataCallback (png_structp png_ptr, png_bytep data, png_size_t length) throw() | |||||
{ | |||||
OutputStream* const out = (OutputStream*) png_ptr->io_ptr; | |||||
const bool ok = out->write (data, length); | |||||
(void) ok; | |||||
jassert (ok); | |||||
} | |||||
bool juce_writePNGImageToStream (const Image& image, OutputStream& out) throw() | |||||
{ | |||||
const int width = image.getWidth(); | |||||
const int height = image.getHeight(); | |||||
png_structp pngWriteStruct = png_create_write_struct (PNG_LIBPNG_VER_STRING, 0, 0, 0); | |||||
if (pngWriteStruct == 0) | |||||
return false; | |||||
png_infop pngInfoStruct = png_create_info_struct (pngWriteStruct); | |||||
if (pngInfoStruct == 0) | |||||
{ | |||||
png_destroy_write_struct (&pngWriteStruct, (png_infopp) 0); | |||||
return false; | |||||
} | |||||
png_set_write_fn (pngWriteStruct, &out, pngWriteDataCallback, 0); | |||||
png_set_IHDR (pngWriteStruct, pngInfoStruct, width, height, 8, | |||||
image.hasAlphaChannel() ? PNG_COLOR_TYPE_RGB_ALPHA | |||||
: PNG_COLOR_TYPE_RGB, | |||||
PNG_INTERLACE_NONE, | |||||
PNG_COMPRESSION_TYPE_BASE, | |||||
PNG_FILTER_TYPE_BASE); | |||||
png_bytep rowData = (png_bytep) juce_malloc (width * 4 * sizeof (png_byte)); | |||||
png_color_8 sig_bit; | |||||
sig_bit.red = 8; | |||||
sig_bit.green = 8; | |||||
sig_bit.blue = 8; | |||||
sig_bit.alpha = 8; | |||||
png_set_sBIT (pngWriteStruct, pngInfoStruct, &sig_bit); | |||||
png_write_info (pngWriteStruct, pngInfoStruct); | |||||
png_set_shift (pngWriteStruct, &sig_bit); | |||||
png_set_packing (pngWriteStruct); | |||||
for (int y = 0; y < height; ++y) | |||||
{ | |||||
uint8* dst = (uint8*) rowData; | |||||
int stride, pixelStride; | |||||
const uint8* pixels = image.lockPixelDataReadOnly (0, y, width, 1, stride, pixelStride); | |||||
const uint8* src = pixels; | |||||
if (image.hasAlphaChannel()) | |||||
{ | |||||
for (int i = width; --i >= 0;) | |||||
{ | |||||
PixelARGB p (*(const PixelARGB*) src); | |||||
p.unpremultiply(); | |||||
*dst++ = p.getRed(); | |||||
*dst++ = p.getGreen(); | |||||
*dst++ = p.getBlue(); | |||||
*dst++ = p.getAlpha(); | |||||
src += pixelStride; | |||||
} | |||||
} | |||||
else | |||||
{ | |||||
for (int i = width; --i >= 0;) | |||||
{ | |||||
*dst++ = ((const PixelRGB*) src)->getRed(); | |||||
*dst++ = ((const PixelRGB*) src)->getGreen(); | |||||
*dst++ = ((const PixelRGB*) src)->getBlue(); | |||||
src += pixelStride; | |||||
} | |||||
} | |||||
png_write_rows (pngWriteStruct, &rowData, 1); | |||||
image.releasePixelDataReadOnly (pixels); | |||||
} | |||||
juce_free (rowData); | |||||
png_write_end (pngWriteStruct, pngInfoStruct); | |||||
png_destroy_write_struct (&pngWriteStruct, &pngInfoStruct); | |||||
out.flush(); | |||||
return true; | |||||
} | |||||
END_JUCE_NAMESPACE | |||||
/* | |||||
============================================================================== | |||||
This file is part of the JUCE library - "Jules' Utility Class Extensions" | |||||
Copyright 2004-7 by Raw Material Software ltd. | |||||
------------------------------------------------------------------------------ | |||||
JUCE can be redistributed and/or modified under the terms of the | |||||
GNU General Public License, as published by the Free Software Foundation; | |||||
either version 2 of the License, or (at your option) any later version. | |||||
JUCE is distributed in the hope that it will be useful, | |||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
GNU General Public License for more details. | |||||
You should have received a copy of the GNU General Public License | |||||
along with JUCE; if not, visit www.gnu.org/licenses or write to the | |||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330, | |||||
Boston, MA 02111-1307 USA | |||||
------------------------------------------------------------------------------ | |||||
If you'd like to release a closed-source product which uses JUCE, commercial | |||||
licenses are also available: visit www.rawmaterialsoftware.com/juce for | |||||
more information. | |||||
============================================================================== | |||||
*/ | |||||
#include "../../../../../juce_core/basics/juce_StandardHeader.h" | |||||
#ifdef _MSC_VER | |||||
#pragma warning (push) | |||||
#pragma warning (disable: 4390 4611) | |||||
#endif | |||||
namespace zlibNamespace | |||||
{ | |||||
#undef OS_CODE | |||||
#undef fdopen | |||||
#include "../../../../../juce_core/io/streams/zlib/zlib.h" | |||||
#undef OS_CODE | |||||
} | |||||
namespace pnglibNamespace | |||||
{ | |||||
using namespace zlibNamespace; | |||||
using ::malloc; | |||||
using ::free; | |||||
extern "C" | |||||
{ | |||||
using ::abs; | |||||
#define PNG_INTERNAL | |||||
#define NO_DUMMY_DECL | |||||
#define PNG_SETJMP_NOT_SUPPORTED | |||||
#include "pnglib/png.h" | |||||
#include "pnglib/pngconf.h" | |||||
#define PNG_NO_EXTERN | |||||
#include "pnglib/png.c" | |||||
#include "pnglib/pngerror.c" | |||||
#include "pnglib/pngget.c" | |||||
#include "pnglib/pngmem.c" | |||||
#include "pnglib/pngread.c" | |||||
#include "pnglib/pngpread.c" | |||||
#include "pnglib/pngrio.c" | |||||
#include "pnglib/pngrtran.c" | |||||
#include "pnglib/pngrutil.c" | |||||
#include "pnglib/pngset.c" | |||||
#include "pnglib/pngtrans.c" | |||||
#include "pnglib/pngwio.c" | |||||
#include "pnglib/pngwrite.c" | |||||
#include "pnglib/pngwtran.c" | |||||
#include "pnglib/pngwutil.c" | |||||
} | |||||
} | |||||
#ifdef _MSC_VER | |||||
#pragma warning (pop) | |||||
#endif | |||||
BEGIN_JUCE_NAMESPACE | |||||
#include "../juce_Image.h" | |||||
#include "../../../../../juce_core/io/juce_InputStream.h" | |||||
#include "../../../../../juce_core/io/juce_OutputStream.h" | |||||
#include "../../colour/juce_PixelFormats.h" | |||||
using namespace pnglibNamespace; | |||||
using ::malloc; | |||||
using ::free; | |||||
//============================================================================== | |||||
static void pngReadCallback (png_structp pngReadStruct, png_bytep data, png_size_t length) throw() | |||||
{ | |||||
InputStream* const in = (InputStream*) png_get_io_ptr (pngReadStruct); | |||||
in->read (data, (int) length); | |||||
} | |||||
struct PNGErrorStruct {}; | |||||
static void pngErrorCallback (png_structp, png_const_charp) | |||||
{ | |||||
throw PNGErrorStruct(); | |||||
} | |||||
//============================================================================== | |||||
Image* juce_loadPNGImageFromStream (InputStream& in) throw() | |||||
{ | |||||
Image* image = 0; | |||||
png_structp pngReadStruct; | |||||
png_infop pngInfoStruct; | |||||
pngReadStruct = png_create_read_struct (PNG_LIBPNG_VER_STRING, 0, 0, 0); | |||||
if (pngReadStruct != 0) | |||||
{ | |||||
pngInfoStruct = png_create_info_struct (pngReadStruct); | |||||
if (pngInfoStruct == 0) | |||||
{ | |||||
png_destroy_read_struct (&pngReadStruct, 0, 0); | |||||
return 0; | |||||
} | |||||
png_set_error_fn (pngReadStruct, 0, pngErrorCallback, pngErrorCallback); | |||||
// read the header.. | |||||
png_set_read_fn (pngReadStruct, &in, pngReadCallback); | |||||
png_uint_32 width, height; | |||||
int bitDepth, colorType, interlaceType; | |||||
try | |||||
{ | |||||
png_read_info (pngReadStruct, pngInfoStruct); | |||||
png_get_IHDR (pngReadStruct, pngInfoStruct, | |||||
&width, &height, | |||||
&bitDepth, &colorType, | |||||
&interlaceType, 0, 0); | |||||
} | |||||
catch (...) | |||||
{ | |||||
png_destroy_read_struct (&pngReadStruct, 0, 0); | |||||
return 0; | |||||
} | |||||
if (bitDepth == 16) | |||||
png_set_strip_16 (pngReadStruct); | |||||
if (colorType == PNG_COLOR_TYPE_PALETTE) | |||||
png_set_expand (pngReadStruct); | |||||
if (bitDepth < 8) | |||||
png_set_expand (pngReadStruct); | |||||
if (png_get_valid (pngReadStruct, pngInfoStruct, PNG_INFO_tRNS)) | |||||
png_set_expand (pngReadStruct); | |||||
if (colorType == PNG_COLOR_TYPE_GRAY || colorType == PNG_COLOR_TYPE_GRAY_ALPHA) | |||||
png_set_gray_to_rgb (pngReadStruct); | |||||
png_set_add_alpha (pngReadStruct, 0xff, PNG_FILLER_AFTER); | |||||
const bool hasAlphaChan = (colorType & PNG_COLOR_MASK_ALPHA) != 0 | |||||
|| pngInfoStruct->num_trans > 0; | |||||
// Load the image into a temp buffer in the pnglib format.. | |||||
uint8* const tempBuffer = (uint8*) juce_malloc (height * (width << 2)); | |||||
png_bytepp rows = (png_bytepp) juce_malloc (sizeof (png_bytep) * height); | |||||
int y; | |||||
for (y = (int) height; --y >= 0;) | |||||
rows[y] = (png_bytep) (tempBuffer + (width << 2) * y); | |||||
bool crashed = false; | |||||
try | |||||
{ | |||||
png_read_image (pngReadStruct, rows); | |||||
png_read_end (pngReadStruct, pngInfoStruct); | |||||
} | |||||
catch (...) | |||||
{ | |||||
crashed = true; | |||||
} | |||||
juce_free (rows); | |||||
png_destroy_read_struct (&pngReadStruct, &pngInfoStruct, 0); | |||||
if (crashed) | |||||
return 0; | |||||
// now convert the data to a juce image format.. | |||||
image = new Image (hasAlphaChan ? Image::ARGB : Image::RGB, | |||||
width, height, hasAlphaChan); | |||||
int stride, pixelStride; | |||||
uint8* const pixels = image->lockPixelDataReadWrite (0, 0, width, height, stride, pixelStride); | |||||
uint8* srcRow = tempBuffer; | |||||
uint8* destRow = pixels; | |||||
for (y = 0; y < (int) height; ++y) | |||||
{ | |||||
const uint8* src = srcRow; | |||||
srcRow += (width << 2); | |||||
uint8* dest = destRow; | |||||
destRow += stride; | |||||
if (hasAlphaChan) | |||||
{ | |||||
for (int i = width; --i >= 0;) | |||||
{ | |||||
((PixelARGB*) dest)->setARGB (src[3], src[0], src[1], src[2]); | |||||
((PixelARGB*) dest)->premultiply(); | |||||
dest += pixelStride; | |||||
src += 4; | |||||
} | |||||
} | |||||
else | |||||
{ | |||||
for (int i = width; --i >= 0;) | |||||
{ | |||||
((PixelRGB*) dest)->setARGB (0, src[0], src[1], src[2]); | |||||
dest += pixelStride; | |||||
src += 4; | |||||
} | |||||
} | |||||
} | |||||
image->releasePixelDataReadWrite (pixels); | |||||
juce_free (tempBuffer); | |||||
} | |||||
return image; | |||||
} | |||||
//============================================================================== | |||||
static void pngWriteDataCallback (png_structp png_ptr, png_bytep data, png_size_t length) throw() | |||||
{ | |||||
OutputStream* const out = (OutputStream*) png_ptr->io_ptr; | |||||
const bool ok = out->write (data, length); | |||||
(void) ok; | |||||
jassert (ok); | |||||
} | |||||
bool juce_writePNGImageToStream (const Image& image, OutputStream& out) throw() | |||||
{ | |||||
const int width = image.getWidth(); | |||||
const int height = image.getHeight(); | |||||
png_structp pngWriteStruct = png_create_write_struct (PNG_LIBPNG_VER_STRING, 0, 0, 0); | |||||
if (pngWriteStruct == 0) | |||||
return false; | |||||
png_infop pngInfoStruct = png_create_info_struct (pngWriteStruct); | |||||
if (pngInfoStruct == 0) | |||||
{ | |||||
png_destroy_write_struct (&pngWriteStruct, (png_infopp) 0); | |||||
return false; | |||||
} | |||||
png_set_write_fn (pngWriteStruct, &out, pngWriteDataCallback, 0); | |||||
png_set_IHDR (pngWriteStruct, pngInfoStruct, width, height, 8, | |||||
image.hasAlphaChannel() ? PNG_COLOR_TYPE_RGB_ALPHA | |||||
: PNG_COLOR_TYPE_RGB, | |||||
PNG_INTERLACE_NONE, | |||||
PNG_COMPRESSION_TYPE_BASE, | |||||
PNG_FILTER_TYPE_BASE); | |||||
png_bytep rowData = (png_bytep) juce_malloc (width * 4 * sizeof (png_byte)); | |||||
png_color_8 sig_bit; | |||||
sig_bit.red = 8; | |||||
sig_bit.green = 8; | |||||
sig_bit.blue = 8; | |||||
sig_bit.alpha = 8; | |||||
png_set_sBIT (pngWriteStruct, pngInfoStruct, &sig_bit); | |||||
png_write_info (pngWriteStruct, pngInfoStruct); | |||||
png_set_shift (pngWriteStruct, &sig_bit); | |||||
png_set_packing (pngWriteStruct); | |||||
for (int y = 0; y < height; ++y) | |||||
{ | |||||
uint8* dst = (uint8*) rowData; | |||||
int stride, pixelStride; | |||||
const uint8* pixels = image.lockPixelDataReadOnly (0, y, width, 1, stride, pixelStride); | |||||
const uint8* src = pixels; | |||||
if (image.hasAlphaChannel()) | |||||
{ | |||||
for (int i = width; --i >= 0;) | |||||
{ | |||||
PixelARGB p (*(const PixelARGB*) src); | |||||
p.unpremultiply(); | |||||
*dst++ = p.getRed(); | |||||
*dst++ = p.getGreen(); | |||||
*dst++ = p.getBlue(); | |||||
*dst++ = p.getAlpha(); | |||||
src += pixelStride; | |||||
} | |||||
} | |||||
else | |||||
{ | |||||
for (int i = width; --i >= 0;) | |||||
{ | |||||
*dst++ = ((const PixelRGB*) src)->getRed(); | |||||
*dst++ = ((const PixelRGB*) src)->getGreen(); | |||||
*dst++ = ((const PixelRGB*) src)->getBlue(); | |||||
src += pixelStride; | |||||
} | |||||
} | |||||
png_write_rows (pngWriteStruct, &rowData, 1); | |||||
image.releasePixelDataReadOnly (pixels); | |||||
} | |||||
juce_free (rowData); | |||||
png_write_end (pngWriteStruct, pngInfoStruct); | |||||
png_destroy_write_struct (&pngWriteStruct, &pngInfoStruct); | |||||
out.flush(); | |||||
return true; | |||||
} | |||||
END_JUCE_NAMESPACE |
@@ -42,8 +42,8 @@ class JUCE_API BlowFish | |||||
{ | { | ||||
public: | public: | ||||
//============================================================================== | //============================================================================== | ||||
/** Creates an object that can encode/decode based on the specified key. | |||||
/** Creates an object that can encode/decode based on the specified key. | |||||
The key data can be up to 72 bytes long. | The key data can be up to 72 bytes long. | ||||
*/ | */ | ||||
BlowFish (const uint8* keyData, int keyBytes); | BlowFish (const uint8* keyData, int keyBytes); | ||||
@@ -40,7 +40,7 @@ void* juce_findFileStart (const String& directory, const String& wildCard, Strin | |||||
bool* isDirectory, bool* isHidden, int64* fileSize, | bool* isDirectory, bool* isHidden, int64* fileSize, | ||||
Time* modTime, Time* creationTime, bool* isReadOnly) throw(); | Time* modTime, Time* creationTime, bool* isReadOnly) throw(); | ||||
bool juce_findFileNext (void* handle, String& resultFile, | bool juce_findFileNext (void* handle, String& resultFile, | ||||
bool* isDirectory, bool* isHidden, int64* fileSize, | |||||
bool* isDirectory, bool* isHidden, int64* fileSize, | |||||
Time* modTime, Time* creationTime, bool* isReadOnly) throw(); | Time* modTime, Time* creationTime, bool* isReadOnly) throw(); | ||||
void juce_findFileClose (void* handle) throw(); | void juce_findFileClose (void* handle) throw(); | ||||
@@ -86,12 +86,12 @@ const String juce_getVolumeLabel (const String& filenameOnVolume, int& volumeSer | |||||
// juce_firstResultFile gets the name of the file (not the whole pathname) and | // juce_firstResultFile gets the name of the file (not the whole pathname) and | ||||
// the other pointers, if non-null, are set based on the properties of the file. | // the other pointers, if non-null, are set based on the properties of the file. | ||||
void* juce_findFileStart (const String& directory, const String& wildCard, String& firstResultFile, | void* juce_findFileStart (const String& directory, const String& wildCard, String& firstResultFile, | ||||
bool* isDirectory, bool* isHidden, int64* fileSize, Time* modTime, | |||||
bool* isDirectory, bool* isHidden, int64* fileSize, Time* modTime, | |||||
Time* creationTime, bool* isReadOnly) throw(); | Time* creationTime, bool* isReadOnly) throw(); | ||||
// returns false when no more files are found | // returns false when no more files are found | ||||
bool juce_findFileNext (void* handle, String& resultFile, | bool juce_findFileNext (void* handle, String& resultFile, | ||||
bool* isDirectory, bool* isHidden, int64* fileSize, | |||||
bool* isDirectory, bool* isHidden, int64* fileSize, | |||||
Time* modTime, Time* creationTime, bool* isReadOnly) throw(); | Time* modTime, Time* creationTime, bool* isReadOnly) throw(); | ||||
void juce_findFileClose (void* handle) throw(); | void juce_findFileClose (void* handle) throw(); | ||||
@@ -191,7 +191,7 @@ public: | |||||
createHeadersAndPostData (url); | createHeadersAndPostData (url); | ||||
headers += extraHeaders; | headers += extraHeaders; | ||||
if (! headers.endsWithChar (T('\n'))) | if (! headers.endsWithChar (T('\n'))) | ||||
headers << "\r\n"; | headers << "\r\n"; | ||||
@@ -29,9 +29,9 @@ const char inflate_copyright[] = | |||||
table index bits. It will differ if the request is greater than the | table index bits. It will differ if the request is greater than the | ||||
longest code or if it is less than the shortest code. | longest code or if it is less than the shortest code. | ||||
*/ | */ | ||||
int inflate_table (codetype type, | |||||
unsigned short FAR *lens, | |||||
unsigned codes, | |||||
int inflate_table (codetype type, | |||||
unsigned short FAR *lens, | |||||
unsigned codes, | |||||
code FAR * FAR *table, | code FAR * FAR *table, | ||||
unsigned FAR *bits, | unsigned FAR *bits, | ||||
unsigned short FAR *work) | unsigned short FAR *work) | ||||
@@ -1167,7 +1167,7 @@ local void bi_windup (deflate_state *s) | |||||
* Copy a stored block, storing first the length and its | * Copy a stored block, storing first the length and its | ||||
* one's complement if requested. | * one's complement if requested. | ||||
*/ | */ | ||||
local void copy_block(deflate_state *s, | |||||
local void copy_block(deflate_state *s, | |||||
charf *buf, /* the input data */ | charf *buf, /* the input data */ | ||||
unsigned len, /* its length */ | unsigned len, /* its length */ | ||||
int header) /* true if block header must be written */ | int header) /* true if block header must be written */ | ||||
@@ -81,7 +81,7 @@ public: | |||||
char buffer [30]; | char buffer [30]; | ||||
if (inputStream != 0 | |||||
if (inputStream != 0 | |||||
&& inputStream->setPosition (zei.streamOffset) | && inputStream->setPosition (zei.streamOffset) | ||||
&& inputStream->read (buffer, 30) == 30 | && inputStream->read (buffer, 30) == 30 | ||||
&& littleEndianInt (buffer) == 0x04034b50) | && littleEndianInt (buffer) == 0x04034b50) | ||||
@@ -62,7 +62,7 @@ public: | |||||
ZipFile (const File& file); | ZipFile (const File& file); | ||||
/** Creates a ZipFile for an input source. | /** Creates a ZipFile for an input source. | ||||
The inputSource object will be owned by the zip file, which will delete | The inputSource object will be owned by the zip file, which will delete | ||||
it later when not needed. | it later when not needed. | ||||
*/ | */ | ||||
@@ -728,7 +728,7 @@ public: | |||||
This will replace the contents of the string with the output of this | This will replace the contents of the string with the output of this | ||||
formatted printf. | formatted printf. | ||||
Note that using the %s token with a juce string is probably a bad idea, as | |||||
Note that using the %s token with a juce string is probably a bad idea, as | |||||
this may expect differect encodings on different platforms. | this may expect differect encodings on different platforms. | ||||
@see formatted | @see formatted | ||||
@@ -740,7 +740,7 @@ public: | |||||
This will return a string which is the result of a sprintf using the | This will return a string which is the result of a sprintf using the | ||||
arguments passed-in. | arguments passed-in. | ||||
Note that using the %s token with a juce string is probably a bad idea, as | |||||
Note that using the %s token with a juce string is probably a bad idea, as | |||||
this may expect differect encodings on different platforms. | this may expect differect encodings on different platforms. | ||||
@see printf, vprintf | @see printf, vprintf | ||||
@@ -753,7 +753,7 @@ public: | |||||
formatted printf. Used by other methods, this is public in case it's | formatted printf. Used by other methods, this is public in case it's | ||||
useful for other purposes where you want to pass a va_list through directly. | useful for other purposes where you want to pass a va_list through directly. | ||||
Note that using the %s token with a juce string is probably a bad idea, as | |||||
Note that using the %s token with a juce string is probably a bad idea, as | |||||
this may expect differect encodings on different platforms. | this may expect differect encodings on different platforms. | ||||
@see printf, formatted | @see printf, formatted | ||||