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:
37 AudacityProject &project, bool newDefaults);
38
41 static const std::function<OptionsFactory> DefaultOptionsFactory();
42
45 struct AUDIO_IO_API DefaultOptions : GlobalHook< DefaultOptions,
46 OptionsFactory,
47 DefaultOptionsFactory // default installed implementation
48 >{};
49
51 static AudioIOStartStreamOptions GetDefaultOptions(
52 AudacityProject &project,
53 bool newDefaults = false
56 );
57
58 static ProjectAudioIO &Get( AudacityProject &project );
59 static const ProjectAudioIO &Get( const AudacityProject &project );
60
61 explicit ProjectAudioIO( AudacityProject &project );
62 ProjectAudioIO( const ProjectAudioIO & ) = delete;
65
66 int GetAudioIOToken() const;
67 bool IsAudioActive() const;
68 void SetAudioIOToken(int token);
69
70 const std::shared_ptr<Meter> &GetPlaybackMeter() const;
71 void SetPlaybackMeter(
72 const std::shared_ptr<Meter> &playback);
73 const std::shared_ptr<Meter> &GetCaptureMeter() const;
74 void SetCaptureMeter(
75 const std::shared_ptr<Meter> &capture);
76
77 // Speed play
78 double GetPlaySpeed() const {
79 return mPlaySpeed.load( std::memory_order_relaxed ); }
80 void SetPlaySpeed( double value );
81
82private:
84
85 // Project owned meters
86 std::shared_ptr<Meter> mPlaybackMeter;
87 std::shared_ptr<Meter> mCaptureMeter;
88
89 // This is atomic because scrubber may read it in a separate thread from
90 // the main
91 std::atomic<double> mPlaySpeed{};
92
93 int mAudioIOToken{ -1 };
94};
95
96#endif
Utility ClientData::Site to register hooks into a host class that attach client data.
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
Global function-valued variable, adding a convenient Call()
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
AudioIOStartStreamOptions(AudacityProject &project, bool newDefaults) OptionsFactory
Type of function constructing AudioIOStartStreamOptions.
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:194
struct holding stream options, including a pointer to the time warp info and AudioIOListener and whet...
Definition: AudioIOBase.h:44
A convenient default parameter for class template Site.
Definition: ClientData.h:28