tracktion-engine 3.0-10-g034fdde4aa5
Tracktion Engine — High level data model for audio applications

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_WaveInputDevice.h
Go to the documentation of this file.
1 /*
2 ,--. ,--. ,--. ,--.
3 ,-' '-.,--.--.,--,--.,---.| |,-.,-' '-.`--' ,---. ,--,--, Copyright 2024
4 '-. .-'| .--' ,-. | .--'| /'-. .-',--.| .-. || \ Tracktion Software
5 | | | | \ '-' \ `--.| \ \ | | | |' '-' '| || | Corporation
6 `---' `--' `--`--'`---'`--'`--' `---' `--' `---' `--''--' www.tracktion.com
7
8 Tracktion Engine uses a GPL/commercial licence - see LICENCE.md for details.
9*/
10
11namespace tracktion { inline namespace engine
12{
13
20{
21public:
22 //==============================================================================
24 ~WaveInputDevice() override;
25
26 static juce::StringArray getMergeModes();
27 juce::StringArray getRecordFormatNames();
28
29 void resetToDefault();
30 void setEnabled (bool) override;
31
32 DeviceType getDeviceType() const override { return deviceType; }
34
35 //==============================================================================
36 void setRecordAdjustmentMs (double ms);
37 double getRecordAdjustmentMs() const { return recordAdjustMs; }
38 bool isStereoPair() const;
39 void setStereoPair (bool);
40 juce::Array<int> getAvailableBitDepths() const;
41 void setBitDepth (int);
42 int getBitDepth() const { return bitDepth; }
43 void checkBitDepth();
44 void setInputGainDb (float gain);
45 float getInputGainDb() const { return inputGainDb; }
46 void setRecordTriggerDb (float);
47 float getRecordTriggerDb() const { return recordTriggerDb; }
48 void setFilenameMask (const juce::String&);
49 juce::String getFilenameMask() const { return filenameMask; }
50 void setFilenameMaskToDefault();
51 static juce::String getDefaultMask();
52
53 void setOutputFormat (const juce::String&);
54 juce::String getOutputFormat() const { return outputFormat; }
55 void setMergeMode (const juce::String&);
56 juce::String getMergeMode() const;
57
58 const std::vector<ChannelIndex>& getChannels() const noexcept { return deviceChannels; }
59 const juce::AudioChannelSet& getChannelSet() const noexcept { return channelSet; }
60
61 //==============================================================================
62 void masterTimeUpdate (double) override {}
63 void consumeNextAudioBlock (const float* const* allChannels, int numChannels, int numSamples, double streamTime);
64
65 RetrospectiveRecordBuffer* getRetrospectiveRecordBuffer() { return retrospectiveBuffer.get(); }
66 void updateRetrospectiveBufferLength (double length) override;
67
68 //==============================================================================
70
71protected:
72 juce::String openDevice();
73 void closeDevice();
74
75private:
76 friend class DeviceManager;
77 friend class WaveInputDeviceInstance;
78
79 const std::vector<ChannelIndex> deviceChannels;
80 const DeviceType deviceType;
81 const juce::AudioChannelSet channelSet;
82
83 juce::String filenameMask;
84 float inputGainDb = 0;
85 juce::String outputFormat;
86 int bitDepth = 0, mergeMode = 0;
87 float recordTriggerDb = 0;
88 double recordAdjustMs = 0;
90
91 void loadProps();
92 void saveProps() override;
93 juce::AudioFormat* getFormatToUse() const;
94
96 juce::CriticalSection instanceLock;
97
98 void addInstance (WaveInputDeviceInstance*);
99 void removeInstance (WaveInputDeviceInstance*);
100
101 TimeDuration getAdjustmentSeconds();
102
104};
105
106
107//==============================================================================
109 private juce::Timer
110{
111public:
112 //==============================================================================
114 ~WaveInputRecordingThread() override;
115
116 //==============================================================================
118 {
119 ScopedInitialiser (WaveInputRecordingThread& t) : owner (t) { owner.addUser(); }
120 ~ScopedInitialiser() { owner.removeUser(); }
121
123 };
124
125 void addUser();
126 void removeUser();
127
128 //==============================================================================
129 void addBlockToRecord (AudioFileWriter&, const juce::AudioBuffer<float>&,
130 int start, int numSamples, const RecordingThumbnailManager::Thumbnail::Ptr&);
131 void waitForWriterToFinish (AudioFileWriter&);
132 void run() override;
133 void timerCallback() override;
134
135 Engine& engine;
136
137private:
138 int activeUsers = 0;
139 bool hasWarned = false, hasSentStop = false;
140
141 struct BlockQueue;
143
144 void prepareToStart();
145 void flushAndStop();
146
148};
149
150}} // namespace tracktion { inline namespace engine
Smart wrapper for writing to an audio file.
The Engine is the central class for all tracktion sessions.
An instance of an InputDevice that's available to an Edit.
Represents an input device.
DeviceType
enum to allow quick querying of the device type.
InputDeviceInstance * createInstance(EditPlaybackContext &) override
Creates an instance to use for a given playback context.
juce::String getSelectableDescription() override
Subclasses must return a description of what they are.
void masterTimeUpdate(double) override
This is a bit of a hack but allows the time for MIDI devices to be set through the base class interfa...
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Represents a duration in real-life time.
Describes a WaveDevice from which the WaveOutputDevice and WaveInputDevice lists will be built.