Audacity 3.2.0
ProjectAudioIO.h
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5ProjectAudioIO.h
6
7Paul Licameli split from AudacityProject.h
8
9**********************************************************************/
10
11#ifndef __PROJECT_AUDIO_IO__
12#define __PROJECT_AUDIO_IO__
13
14#include "ClientData.h" // to inherit
15#include "GlobalVariable.h"
16#include "Observer.h" // to inherit
17#include <wx/weakref.h>
18
19#include <atomic>
20#include <memory>
21class AudacityProject;
23class Meter;
24
26
29class AUDIO_IO_API ProjectAudioIO final
30 : public ClientData::Base
31 , public Observer::Publisher<SpeedChangeMessage>
32{
33public:
36 DefaultOptionsFactory(AudacityProject &project, bool newDefaults);
37
40 struct AUDIO_IO_API DefaultOptions : DefaultedGlobalHook<DefaultOptions,
41 DefaultOptionsFactory
42 >{};
43
45 static AudioIOStartStreamOptions GetDefaultOptions(
47 bool newDefaults = false
50 );
51
53 static const ProjectAudioIO &Get( const AudacityProject &project );
54
56 ProjectAudioIO( const ProjectAudioIO & ) = delete;
59
60 int GetAudioIOToken() const;
61 bool IsAudioActive() const;
62 void SetAudioIOToken(int token);
63
64 const std::shared_ptr<Meter> &GetPlaybackMeter() const;
65 void SetPlaybackMeter(
66 const std::shared_ptr<Meter> &playback);
67 const std::shared_ptr<Meter> &GetCaptureMeter() const;
68 void SetCaptureMeter(
69 const std::shared_ptr<Meter> &capture);
70
71 // Speed play
72 double GetPlaySpeed() const {
73 return mPlaySpeed.load( std::memory_order_relaxed ); }
74 void SetPlaySpeed( double value );
75
76private:
78
79 // Project owned meters
80 std::shared_ptr<Meter> mPlaybackMeter;
81 std::shared_ptr<Meter> mCaptureMeter;
82
83 // This is atomic because scrubber may read it in a separate thread from
84 // the main
85 std::atomic<double> mPlaySpeed{};
86
87 int mAudioIOToken{ -1 };
88};
89
90#endif
Utility ClientData::Site to register hooks into a host class that attach client data.
const auto project
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
AudioIO uses this to send sample buffers for real-time display updates.
Definition: Meter.h:16
An object that sends messages to an open-ended list of subscribed callbacks.
Definition: Observer.h:108
ProjectAudioIO & operator=(const ProjectAudioIO &)=delete
std::shared_ptr< Meter > mPlaybackMeter
double GetPlaySpeed() const
AudacityProject & mProject
ProjectAudioIO(const ProjectAudioIO &)=delete
std::shared_ptr< Meter > mCaptureMeter
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:202
struct holding stream options, including a pointer to the time warp info and AudioIOListener and whet...
Definition: AudioIOBase.h:46
A convenient default parameter for class template Site.
Definition: ClientData.h:29