Skip to content

Commit

Permalink
Revert "Move PlaybackComponent autoplay handling to update()"
Browse files Browse the repository at this point in the history
This reverts commit 9e1ddbb.
  • Loading branch information
stijnvanbeek committed Jan 20, 2025
1 parent 9e1ddbb commit 8084488
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion demos/audiovisualfft/data/objects.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
],
"Gain": 1.0,
"StereoPanning": 0.5,
"AutoPlay": true,
"AutoPlay": false,
"StartPosition": 17000.0,
"Duration": 0.0,
"FadeInTime": 0.0,
Expand Down
9 changes: 9 additions & 0 deletions demos/audiovisualfft/src/audiovisualfftapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ namespace nap
// Connect reload slot
mResourceManager->mPostResourcesLoadedSignal.connect(mReloadSlot);

// Start audio file playback
auto audioEntity = mScene->findEntity("AudioEntity");
if (!errorState.check(audioEntity != nullptr, "unable to find entity with name: %s", "AudioEntity"))
return false;
auto playbackComponent = audioEntity->findComponent<audio::PlaybackComponentInstance>();
if (!errorState.check(playbackComponent != nullptr, "unable to find PlaybackComponentInstance"))
return false;
playbackComponent->start();

// All done!
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ namespace nap
mFadeInTime = mResource->mFadeInTime;
mFadeOutTime = mResource->mFadeOutTime;
mPitch = mResource->mPitch;
mAutoPlay = mResource->mAutoPlay;

mAudioService = getEntityInstance()->getCore()->getService<AudioService>();
mNodeManager = &mAudioService->getNodeManager();
Expand Down Expand Up @@ -98,18 +97,15 @@ namespace nap
mGainControls.emplace_back(std::move(gainControl));
}

if (mResource->mAutoPlay)
start(mResource->mStartPosition, mResource->mDuration);

return true;
}


void PlaybackComponentInstance::update(double deltaTime)
{
if (mAutoPlay)
{
start(mResource->mStartPosition, mResource->mDuration);
mAutoPlay = false;
}

if (mPlaying)
{
mCurrentPlayingTime += deltaTime * 1000.f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,9 @@ namespace nap
TimeValue mDuration = 0;
TimeValue mCurrentPlayingTime = 0;
std::vector<int> mChannelRouting;
bool mAutoPlay = false;


bool mPlaying = false; // Indicates wether the component is currently playing

PlaybackComponent* mResource = nullptr; // The component's resource
NodeManager* mNodeManager = nullptr; // The audio node manager this component's audio nodes are managed by
AudioService* mAudioService = nullptr;
Expand Down

6 comments on commit 8084488

@cklosters
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity Public / Package NAP Linux Build 313 is now running

@cklosters
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity Public / Package NAP Win64 Build 321 is now running

@cklosters
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity Public / Package NAP Raspberry Pi Build 1799 is now running

@cklosters
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity Public / Package NAP Linux Build 313 outcome was SUCCESS
Summary: Running Build time: 00:32:45

@cklosters
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity Public / Package NAP Win64 Build 321 outcome was SUCCESS
Summary: Running Build time: 00:37:36

@cklosters
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity Public / Package NAP Raspberry Pi Build 1799 outcome was SUCCESS
Summary: Running Build time: 00:44:51

Please sign in to comment.