Skip to content

Commit

Permalink
More audio tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
kunitoki committed Nov 28, 2024
1 parent 7431628 commit 460121d
Show file tree
Hide file tree
Showing 8 changed files with 224 additions and 167 deletions.
6 changes: 6 additions & 0 deletions examples/graphics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,16 @@ cmake_minimum_required(VERSION 3.28)
set (target_name example_graphics)
set (target_version "1.0.0")

set (link_options "")
if ("${yup_platform}" MATCHES "^(emscripten)$")
set (link_options --preload-file ${CMAKE_CURRENT_LIST_DIR}/data/Roboto-Regular.ttf@data/Roboto-Regular.ttf)
endif()

yup_standalone_app (
TARGET_NAME ${target_name}
TARGET_VERSION ${target_version}
TARGET_IDE_GROUP "Examples"
LINK_OPTIONS ${link_options}
MODULES
juce_core
juce_events
Expand Down
13 changes: 7 additions & 6 deletions examples/graphics/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ class CustomWindow
for (int i = 0; i < totalRows * totalColumns; ++i)
addAndMakeVisible (sliders.add (std::make_unique<yup::Slider> (yup::String (i), font)));

//button = std::make_unique<yup::TextButton> ("xyz", font);
//addAndMakeVisible (*button);
button = std::make_unique<yup::TextButton> ("xyz", font);
addAndMakeVisible (*button);

deviceManager.addAudioCallback (this);
deviceManager.initialiseWithDefaultDevices (1, 0);
Expand Down Expand Up @@ -177,7 +177,8 @@ class CustomWindow
int copiedSamples = 0;
while (copiedSamples < numSamples)
{
renderData[readPos % renderData.size()] = inputChannelData[0][copiedSamples];
renderData[readPos % renderData.size()] = inputChannelData[0][copiedSamples]
+ yup::Random::getSystemRandom().nextFloat() * 0.1f - 0.05f;

++copiedSamples;
++readPos;
Expand All @@ -191,7 +192,7 @@ class CustomWindow

void audioDeviceAboutToStart (yup::AudioIODevice* device) override
{
DBG ("audioDeviceAboutToStart");
yup::Logger::outputDebugString ("audioDeviceAboutToStart");

inputData.resize (device->getDefaultBufferSize());
renderData.resize (device->getDefaultBufferSize());
Expand All @@ -200,7 +201,7 @@ class CustomWindow

void audioDeviceStopped() override
{
DBG ("audioDeviceStopped");
yup::Logger::outputDebugString ("audioDeviceStopped");
}

private:
Expand Down Expand Up @@ -244,7 +245,7 @@ struct Application : yup::YUPApplication

const yup::String getApplicationName() override
{
return "yup graphics!";
return "yup! graphics";
}

const yup::String getApplicationVersion() override
Expand Down
6 changes: 5 additions & 1 deletion examples/render/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ struct Application : yup::YUPApplication

const yup::String getApplicationName() override
{
return "yup!";
return "yup! render";
}

const yup::String getApplicationVersion() override
Expand All @@ -198,6 +198,8 @@ struct Application : yup::YUPApplication

void initialise (const yup::String& commandLineParameters) override
{
YUP_PROFILE_START();

yup::Logger::outputDebugString ("Starting app " + commandLineParameters);

window = std::make_unique<CustomWindow>();
Expand All @@ -210,6 +212,8 @@ struct Application : yup::YUPApplication
yup::Logger::outputDebugString ("Shutting down");

window.reset();

YUP_PROFILE_STOP();
}

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ void AudioDeviceManager::createAudioDeviceTypes (OwnedArray<AudioIODeviceType>&
addIfNotNull (list, AudioIODeviceType::createAudioIODeviceType_Oboe());
addIfNotNull (list, AudioIODeviceType::createAudioIODeviceType_OpenSLES());
addIfNotNull (list, AudioIODeviceType::createAudioIODeviceType_Android());
addIfNotNull (list, AudioIODeviceType::createAudioIODeviceType_AudioWorklet());
}

void AudioDeviceManager::addAudioDeviceType (std::unique_ptr<AudioIODeviceType> newDeviceType)
Expand Down
Loading

0 comments on commit 460121d

Please sign in to comment.