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 <wx/weakref.h>
16#include <wx/event.h> // to declare custom event type
17
18#include <atomic>
19#include <memory>
20class AudacityProject;
21class Meter;
22
23// Sent to the project when the play speed changes
24wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
25 EVT_PLAY_SPEED_CHANGE, wxCommandEvent);
26
29class AUDACITY_DLL_API ProjectAudioIO final
30 : public ClientData::Base
31{
32public:
33 static ProjectAudioIO &Get( AudacityProject &project );
34 static const ProjectAudioIO &Get( const AudacityProject &project );
35
36 explicit ProjectAudioIO( AudacityProject &project );
37 ProjectAudioIO( const ProjectAudioIO & ) PROHIBITED;
38 ProjectAudioIO &operator=( const ProjectAudioIO & ) PROHIBITED;
40
41 int GetAudioIOToken() const;
42 bool IsAudioActive() const;
43 void SetAudioIOToken(int token);
44
45 const std::shared_ptr<Meter> &GetPlaybackMeter() const;
46 void SetPlaybackMeter(
47 const std::shared_ptr<Meter> &playback);
48 const std::shared_ptr<Meter> &GetCaptureMeter() const;
49 void SetCaptureMeter(
50 const std::shared_ptr<Meter> &capture);
51
52 // Speed play
53 double GetPlaySpeed() const {
54 return mPlaySpeed.load( std::memory_order_relaxed ); }
55 void SetPlaySpeed( double value );
56
57private:
59
60 // Project owned meters
61 std::shared_ptr<Meter> mPlaybackMeter;
62 std::shared_ptr<Meter> mCaptureMeter;
63
64 // This is atomic because scrubber may read it in a separate thread from
65 // the main
66 std::atomic<double> mPlaySpeed{};
67
68 int mAudioIOToken{ -1 };
69};
70
71#endif
Utility ClientData::Site to register hooks into a host class that attach client data.
wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API, EVT_PLAY_SPEED_CHANGE, wxCommandEvent)
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
AudioIO uses this to send sample buffers for real-time display updates.
Definition: Meter.h:16
std::shared_ptr< Meter > mPlaybackMeter
ProjectAudioIO(const ProjectAudioIO &) PROHIBITED
double GetPlaySpeed() const
ProjectAudioIO & operator=(const ProjectAudioIO &) PROHIBITED
AudacityProject & mProject
std::shared_ptr< Meter > mCaptureMeter
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:26
A convenient default parameter for class template Site.
Definition: ClientData.h:28