From ac626224934e1ad8830603984f84e40f5c703b94 Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 10 Jan 2019 10:32:45 +0000 Subject: [PATCH] Request audio recording permissions in the SimpleFFTDemo when not running in the DemoRunner and added some more exporters to the audio demos --- examples/Audio/AudioAppDemo.h | 11 +++-------- examples/Audio/MPEDemo.h | 2 +- examples/Audio/MidiDemo.h | 2 +- examples/Audio/PluckedStringsDemo.h | 2 +- examples/Audio/SimpleFFTDemo.h | 18 +++++++++++------- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/examples/Audio/AudioAppDemo.h b/examples/Audio/AudioAppDemo.h index b464a7d8a8..fed02dbb89 100644 --- a/examples/Audio/AudioAppDemo.h +++ b/examples/Audio/AudioAppDemo.h @@ -33,7 +33,7 @@ juce_audio_processors, juce_audio_utils, juce_core, juce_data_structures, juce_events, juce_graphics, juce_gui_basics, juce_gui_extra - exporters: xcode_mac, vs2017, xcode_iphone + exporters: xcode_mac, vs2017, linux_make, androidstudio, xcode_iphone moduleFlags: JUCE_STRICT_REFCOUNTEDPOINTER=1 @@ -59,14 +59,9 @@ public: : AudioAppComponent (getSharedAudioDeviceManager (0, 2)) #endif { - setSize (800, 600); - - auto audioDevice = deviceManager.getCurrentAudioDevice(); - auto numInputChannels = (audioDevice != nullptr ? audioDevice->getActiveInputChannels() .countNumberOfSetBits() : 0); - auto numOutputChannels = jmax (audioDevice != nullptr ? audioDevice->getActiveOutputChannels().countNumberOfSetBits() : 2, 2); + setAudioChannels (0, 2); - // Specify the number of input and output channels that we want to open - setAudioChannels (numInputChannels, numOutputChannels); + setSize (800, 600); } ~AudioAppDemo() diff --git a/examples/Audio/MPEDemo.h b/examples/Audio/MPEDemo.h index d6c7fa3c69..b7ef91e81d 100644 --- a/examples/Audio/MPEDemo.h +++ b/examples/Audio/MPEDemo.h @@ -33,7 +33,7 @@ juce_audio_processors, juce_audio_utils, juce_core, juce_data_structures, juce_events, juce_graphics, juce_gui_basics, juce_gui_extra - exporters: xcode_mac, vs2017, linux_make + exporters: xcode_mac, vs2017, linux_make, androidstudio, xcode_iphone moduleFlags: JUCE_STRICT_REFCOUNTEDPOINTER=1 diff --git a/examples/Audio/MidiDemo.h b/examples/Audio/MidiDemo.h index 3d3df92cf0..c12776c706 100644 --- a/examples/Audio/MidiDemo.h +++ b/examples/Audio/MidiDemo.h @@ -33,7 +33,7 @@ juce_audio_processors, juce_audio_utils, juce_core, juce_data_structures, juce_events, juce_graphics, juce_gui_basics, juce_gui_extra - exporters: xcode_mac, vs2017, linux_make, xcode_iphone, androidstudio + exporters: xcode_mac, vs2017, linux_make, androidstudio, xcode_iphone moduleFlags: JUCE_STRICT_REFCOUNTEDPOINTER=1 diff --git a/examples/Audio/PluckedStringsDemo.h b/examples/Audio/PluckedStringsDemo.h index d53701a33e..86b0b17b87 100644 --- a/examples/Audio/PluckedStringsDemo.h +++ b/examples/Audio/PluckedStringsDemo.h @@ -33,7 +33,7 @@ juce_audio_processors, juce_audio_utils, juce_core, juce_data_structures, juce_events, juce_graphics, juce_gui_basics, juce_gui_extra - exporters: xcode_mac, vs2017 + exporters: xcode_mac, vs2017, linux_make, androidstudio, xcode_iphone moduleFlags: JUCE_STRICT_REFCOUNTEDPOINTER=1 diff --git a/examples/Audio/SimpleFFTDemo.h b/examples/Audio/SimpleFFTDemo.h index 4fa8d5d0f4..75a164c7e2 100644 --- a/examples/Audio/SimpleFFTDemo.h +++ b/examples/Audio/SimpleFFTDemo.h @@ -33,7 +33,7 @@ juce_audio_processors, juce_audio_utils, juce_core, juce_data_structures, juce_dsp, juce_events, juce_graphics, juce_gui_basics, juce_gui_extra - exporters: xcode_mac, vs2017 + exporters: xcode_mac, vs2017, linux_make, androidstudio, xcode_iphone moduleFlags: JUCE_STRICT_REFCOUNTEDPOINTER=1 @@ -63,12 +63,16 @@ public: { setOpaque (true); - auto audioDevice = deviceManager.getCurrentAudioDevice(); - auto numInputChannels = jmax (audioDevice != nullptr ? audioDevice->getActiveInputChannels() .countNumberOfSetBits() : 1, 1); - auto numOutputChannels = audioDevice != nullptr ? audioDevice->getActiveOutputChannels().countNumberOfSetBits() : 2; - - // Specify the number of input and output channels that we want to open - setAudioChannels (numInputChannels, numOutputChannels); + #ifndef JUCE_DEMO_RUNNER + RuntimePermissions::request (RuntimePermissions::recordAudio, + [this] (bool granted) + { + int numInputChannels = granted ? 2 : 0; + setAudioChannels (numInputChannels, 2); + }); + #else + setAudioChannels (2, 2); + #endif startTimerHz (60); setSize (700, 500);