From 6f74e96862e6f1168ce19fa3b69a1ed7916dd07a Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 10 Jun 2008 14:36:13 +0000 Subject: [PATCH] --- .../juce_win32_Network.cpp | 4 +- .../src/binarydata/QuickTimeDemo.cpp | 258 +++++++++--------- .../juce_QuickTimeAudioFormat.cpp | 12 +- .../audio_sources/juce_AudioSourcePlayer.cpp | 14 +- .../audio_sources/juce_AudioSourcePlayer.h | 3 + .../gui/components/menus/juce_PopupMenu.h | 4 + src/juce_core/text/juce_String.h | 9 + 7 files changed, 167 insertions(+), 137 deletions(-) diff --git a/build/win32/platform_specific_code/juce_win32_Network.cpp b/build/win32/platform_specific_code/juce_win32_Network.cpp index 317c4a260e..e33ad65a89 100644 --- a/build/win32/platform_specific_code/juce_win32_Network.cpp +++ b/build/win32/platform_specific_code/juce_win32_Network.cpp @@ -100,7 +100,7 @@ void* juce_openInternetFile (const String& url, uc.lpszUrlPath = file; uc.lpszHostName = server; - if (InternetCrackUrl (url, 0, ICU_ESCAPE | ICU_DECODE, &uc)) + if (InternetCrackUrl (url, 0, 0, &uc)) { const bool isFtp = url.startsWithIgnoreCase (T("ftp:")); @@ -129,7 +129,7 @@ void* juce_openInternetFile (const String& url, } else { - const TCHAR* mimeTypes[] = { _T("*"), 0 }; + const TCHAR* mimeTypes[] = { _T("*/*"), 0 }; HINTERNET request = HttpOpenRequest (connection, isPost ? _T("POST") diff --git a/extras/juce demo/src/binarydata/QuickTimeDemo.cpp b/extras/juce demo/src/binarydata/QuickTimeDemo.cpp index 3ad78aefce..f157c06663 100644 --- a/extras/juce demo/src/binarydata/QuickTimeDemo.cpp +++ b/extras/juce demo/src/binarydata/QuickTimeDemo.cpp @@ -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 diff --git a/src/juce_appframework/audio/audio_file_formats/juce_QuickTimeAudioFormat.cpp b/src/juce_appframework/audio/audio_file_formats/juce_QuickTimeAudioFormat.cpp index 1f16fafe58..b3d884e59f 100644 --- a/src/juce_appframework/audio/audio_file_formats/juce_QuickTimeAudioFormat.cpp +++ b/src/juce_appframework/audio/audio_file_formats/juce_QuickTimeAudioFormat.cpp @@ -95,14 +95,12 @@ public: #ifdef WIN32 if (InitializeQTML (0) != noErr) return; -#endif +#elif JUCE_MAC + EnterMoviesOnThread (0); +#endif if (EnterMovies() != noErr) return; -#if JUCE_MAC - EnterMoviesOnThread (0); -#endif - bool opened = juce_OpenQuickTimeMovieFromStream (input_, movie, dataHandle); if (! opened) @@ -233,6 +231,10 @@ public: juce_free (bufferList->mBuffers[0].mData); juce_free (bufferList); + +#if JUCE_MAC + ExitMoviesOnThread (); +#endif } bool read (int** destSamples, diff --git a/src/juce_appframework/audio/audio_sources/juce_AudioSourcePlayer.cpp b/src/juce_appframework/audio/audio_sources/juce_AudioSourcePlayer.cpp index b1f1b38ad8..2d36a6922a 100644 --- a/src/juce_appframework/audio/audio_sources/juce_AudioSourcePlayer.cpp +++ b/src/juce_appframework/audio/audio_sources/juce_AudioSourcePlayer.cpp @@ -42,7 +42,9 @@ AudioSourcePlayer::AudioSourcePlayer() : source (0), sampleRate (0), bufferSize (0), - tempBuffer (2, 8) + tempBuffer (2, 8), + lastGain (1.0f), + gain (1.0f) { } @@ -70,6 +72,11 @@ void AudioSourcePlayer::setSource (AudioSource* newSource) } } +void AudioSourcePlayer::setGain (const float newGain) throw() +{ + gain = newGain; +} + void AudioSourcePlayer::audioDeviceIOCallback (const float** inputChannelData, int totalNumInputChannels, float** outputChannelData, @@ -154,6 +161,11 @@ void AudioSourcePlayer::audioDeviceIOCallback (const float** inputChannelData, info.numSamples = numSamples; source->getNextAudioBlock (info); + + for (int i = info.buffer->getNumChannels(); --i >= 0;) + info.buffer->applyGainRamp (i, info.startSample, info.numSamples, lastGain, gain); + + lastGain = gain; } else { diff --git a/src/juce_appframework/audio/audio_sources/juce_AudioSourcePlayer.h b/src/juce_appframework/audio/audio_sources/juce_AudioSourcePlayer.h index 442c3d42ab..bb2f988534 100644 --- a/src/juce_appframework/audio/audio_sources/juce_AudioSourcePlayer.h +++ b/src/juce_appframework/audio/audio_sources/juce_AudioSourcePlayer.h @@ -80,6 +80,8 @@ public: */ AudioSource* getCurrentSource() const throw() { return source; } + /** Sets a gain to apply to the audio data. */ + void setGain (const float newGain) throw(); //============================================================================== /** Implementation of the AudioIODeviceCallback method. */ @@ -108,6 +110,7 @@ private: float* outputChans [128]; const float* inputChans [128]; AudioSampleBuffer tempBuffer; + float lastGain, gain; AudioSourcePlayer (const AudioSourcePlayer&); const AudioSourcePlayer& operator= (const AudioSourcePlayer&); diff --git a/src/juce_appframework/gui/components/menus/juce_PopupMenu.h b/src/juce_appframework/gui/components/menus/juce_PopupMenu.h index e0bb91fc19..feee351161 100644 --- a/src/juce_appframework/gui/components/menus/juce_PopupMenu.h +++ b/src/juce_appframework/gui/components/menus/juce_PopupMenu.h @@ -259,6 +259,10 @@ public: This is the same as show(), but uses a specific location (in global screen co-ordinates) rather than the current mouse position. + Note that the co-ordinates don't specify the top-left of the menu - they + indicate a point of interest, and the menu will position itself nearby to + this point, trying to keep it fully on-screen. + @see show() */ int showAt (const int screenX, diff --git a/src/juce_core/text/juce_String.h b/src/juce_core/text/juce_String.h index cffc1b5328..7cdac55163 100644 --- a/src/juce_core/text/juce_String.h +++ b/src/juce_core/text/juce_String.h @@ -728,6 +728,9 @@ public: This will replace the contents of the string with the output of this formatted printf. + Note that using the %s token with a juce string is probably a bad idea, as + this may expect differect encodings on different platforms. + @see formatted */ void printf (const tchar* const format, ...) throw(); @@ -737,6 +740,9 @@ public: This will return a string which is the result of a sprintf using the arguments passed-in. + Note that using the %s token with a juce string is probably a bad idea, as + this may expect differect encodings on different platforms. + @see printf, vprintf */ static const String formatted (const tchar* const format, ...) throw(); @@ -747,6 +753,9 @@ public: 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. + Note that using the %s token with a juce string is probably a bad idea, as + this may expect differect encodings on different platforms. + @see printf, formatted */ void vprintf (const tchar* const format, va_list& args) throw();