From d38057b304615ba4fd84cc5a1f293e3eeb8e8056 Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 29 Nov 2011 14:18:53 +0000 Subject: [PATCH] Fixed bugs in the audio demo page, TextLayout, and AudioUnitPluginFormat. --- .../Source/demos/AudioDemoPlaybackPage.cpp | 9 ++++-- .../juce_AudioUnitPluginFormat.mm | 30 +++++++------------ .../juce_graphics/fonts/juce_TextLayout.cpp | 2 +- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/extras/JuceDemo/Source/demos/AudioDemoPlaybackPage.cpp b/extras/JuceDemo/Source/demos/AudioDemoPlaybackPage.cpp index 5ae9eed679..0ba089f8f9 100644 --- a/extras/JuceDemo/Source/demos/AudioDemoPlaybackPage.cpp +++ b/extras/JuceDemo/Source/demos/AudioDemoPlaybackPage.cpp @@ -76,7 +76,7 @@ public: if (thumbnail.getTotalLength() > 0) { double newStart = startTime - wheelIncrementX * (endTime - startTime) / 10.0; - newStart = jlimit (0.0, thumbnail.getTotalLength() - (endTime - startTime), newStart); + newStart = jlimit (0.0, jmax (0.0, thumbnail.getTotalLength() - (endTime - startTime)), newStart); endTime = newStart + (endTime - startTime); startTime = newStart; @@ -124,6 +124,11 @@ public: demoPage->showFile (File (files[0])); } + void mouseDown (const MouseEvent& e) + { + mouseDrag (e); + } + void mouseDrag (const MouseEvent& e) { transportSource.setPosition (jmax (0.0, xToTime ((float) e.x))); @@ -219,7 +224,7 @@ AudioDemoPlaybackPage::AudioDemoPlaybackPage (AudioDeviceManager& deviceManager_ //[Constructor] You can add your own custom stuff here.. formatManager.registerBasicFormats(); - directoryList.setDirectory (File ("/Users/jules/Music/iTunes/iTunes Music/"), true, true); + directoryList.setDirectory (File::getSpecialLocation (File::userHomeDirectory), true, true); thread.startThread (3); fileTreeComp->setColour (FileTreeComponent::backgroundColourId, Colours::white); diff --git a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm index 728c49dee1..70c97fd6f7 100644 --- a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm +++ b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm @@ -598,10 +598,8 @@ public: AudioUnitParameterInfo info; UInt32 sz = sizeof (info); - if (AudioUnitGetProperty (audioUnit, - kAudioUnitProperty_ParameterInfo, - kAudioUnitScope_Global, - parameterIds [index], &info, &sz) == noErr) + if (AudioUnitGetProperty (audioUnit, kAudioUnitProperty_ParameterInfo, + kAudioUnitScope_Global, parameterIds [index], &info, &sz) == noErr) { return (info.flags & kAudioUnitParameterFlag_NonRealTime) == 0; } @@ -616,10 +614,8 @@ public: UInt32 sz = sizeof (CFArrayRef); int num = 0; - if (AudioUnitGetProperty (audioUnit, - kAudioUnitProperty_FactoryPresets, - kAudioUnitScope_Global, - 0, &presets, &sz) == noErr) + if (AudioUnitGetProperty (audioUnit, kAudioUnitProperty_FactoryPresets, + kAudioUnitScope_Global, 0, &presets, &sz) == noErr) { num = (int) CFArrayGetCount (presets); CFRelease (presets); @@ -634,10 +630,8 @@ public: current.presetNumber = 0; UInt32 sz = sizeof (AUPreset); - AudioUnitGetProperty (audioUnit, - kAudioUnitProperty_FactoryPresets, - kAudioUnitScope_Global, - 0, ¤t, &sz); + AudioUnitGetProperty (audioUnit, kAudioUnitProperty_PresentPreset, + kAudioUnitScope_Global, 0, ¤t, &sz); return current.presetNumber; } @@ -648,10 +642,8 @@ public: current.presetNumber = newIndex; current.presetName = 0; - AudioUnitSetProperty (audioUnit, - kAudioUnitProperty_PresentPreset, - kAudioUnitScope_Global, - 0, ¤t, sizeof (AUPreset)); + AudioUnitSetProperty (audioUnit, kAudioUnitProperty_PresentPreset, + kAudioUnitScope_Global, 0, ¤t, sizeof (AUPreset)); } const String getProgramName (int index) @@ -660,10 +652,8 @@ public: CFArrayRef presets; UInt32 sz = sizeof (CFArrayRef); - if (AudioUnitGetProperty (audioUnit, - kAudioUnitProperty_FactoryPresets, - kAudioUnitScope_Global, - 0, &presets, &sz) == noErr) + if (AudioUnitGetProperty (audioUnit, kAudioUnitProperty_FactoryPresets, + kAudioUnitScope_Global, 0, &presets, &sz) == noErr) { for (CFIndex i = 0; i < CFArrayGetCount (presets); ++i) { diff --git a/modules/juce_graphics/fonts/juce_TextLayout.cpp b/modules/juce_graphics/fonts/juce_TextLayout.cpp index 08ca04afea..be3a8ac66b 100644 --- a/modules/juce_graphics/fonts/juce_TextLayout.cpp +++ b/modules/juce_graphics/fonts/juce_TextLayout.cpp @@ -365,7 +365,7 @@ namespace TextLayoutHelpers { const int totalW = (int) layout.getWidth(); - for (int i = 0; i < totalLines; ++i) + for (int i = 0; i < layout.getNumLines(); ++i) { const int lineW = getLineWidth (i); float dx = 0;