Audacity 3.2.0
Mix.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 Mix.h
6
7 Dominic Mazzoni
8 Markus Meyer
9
10***********************************************************************/
11
12#ifndef __AUDACITY_MIX__
13#define __AUDACITY_MIX__
14
15#include "AudioGraphBuffers.h"
16#include "AudioGraphSource.h"
17#include "MixerOptions.h"
18#include "SampleFormat.h"
19#include <functional>
20
21class sampleCount;
22class BoundedEnvelope;
23class TrackList;
24class SampleTrack;
25using SampleTrackConstArray = std::vector < std::shared_ptr < const SampleTrack > >;
26
27class MixerSource;
28
29class SAMPLE_TRACK_API Mixer {
30 public:
35
36 //
37 // Constructor / Destructor
38 //
39
46 Mixer(const SampleTrackConstArray &inputTracks, bool mayThrow,
47 const WarpOptions &warpOptions,
48 double startTime, double stopTime,
49 unsigned numOutChannels, size_t outBufferSize, bool outInterleaved,
50 double outRate, sampleFormat outFormat,
51 bool highQuality = true,
53 MixerSpec *mixerSpec = nullptr,
54 bool applytTrackGains = true);
55
56 Mixer(const Mixer&) = delete;
57 Mixer &operator=(const Mixer&) = delete;
58
59 virtual ~ Mixer();
60
61 size_t BufferSize() const { return mBufferSize; }
62
63 //
64 // Processing
65 //
66
71
75 size_t Process(size_t maxSamples);
76
79 void Restart();
80
83 void Reposition(double t, bool bSkipping = false);
84
85 // Used in scrubbing and other nonuniform playback policies.
86 void SetTimesAndSpeed(
87 double t0, double t1, double speed, bool bSkipping = false);
88 void SetSpeedForKeyboardScrubbing(double speed, double startTime);
89
92 double MixGetCurrentTime();
93
95 constSamplePtr GetBuffer();
96
98 constSamplePtr GetBuffer(int channel);
99
100 private:
101
102 void Clear();
103
104 private:
105
106 // Input
107 const unsigned mNumChannels;
108
109 // Transformations
110 const size_t mBufferSize;
111
112 // Output
114 const bool mHighQuality; // dithering
115 const sampleFormat mFormat; // output format also influences dithering
116 const bool mInterleaved;
117
118 // INPUT
119
120 const std::shared_ptr<TimesAndSpeed> mTimesAndSpeed;
121
122 // BUFFERS
123
124 // Resample into these buffers, or produce directly when not resampling
126
127 // Each channel's data is transformed, including application of
128 // gains and pans, and then (maybe many-to-one) mixer specifications
129 // determine where in mTemp it is accumulated
130 std::vector<std::vector<float>> mTemp;
131
132 // Final result applies dithering and interleaving
133 const std::vector<SampleBuffer> mBuffer;
134
135 std::vector<MixerSource> mSources;
136};
137#endif
std::vector< std::shared_ptr< const SampleTrack > > SampleTrackConstArray
Definition: Mix.h:25
sampleFormat
Definition: SampleFormat.h:29
const char * constSamplePtr
Definition: SampleFormat.h:50
Accumulates (non-interleaved) data during effect processing.
Functions for doing the mixdown of the tracks.
Definition: Mix.h:29
AudioGraph::Buffers mFloatBuffers
Definition: Mix.h:125
const std::vector< SampleBuffer > mBuffer
Definition: Mix.h:133
const bool mApplyTrackGains
Definition: Mix.h:113
const sampleFormat mFormat
Definition: Mix.h:115
std::vector< std::vector< float > > mTemp
Definition: Mix.h:130
void Restart()
const unsigned mNumChannels
Definition: Mix.h:107
const bool mInterleaved
Definition: Mix.h:116
const size_t mBufferSize
Definition: Mix.h:110
Mixer(const Mixer &)=delete
const bool mHighQuality
Definition: Mix.h:114
std::vector< MixerSource > mSources
Definition: Mix.h:135
size_t BufferSize() const
Definition: Mix.h:61
Mixer & operator=(const Mixer &)=delete
const std::shared_ptr< TimesAndSpeed > mTimesAndSpeed
Definition: Mix.h:120
A matrix of booleans, one row per input channel, column per output.
Definition: MixerOptions.h:29
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:1336
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19
Immutable structure is an argument to Mixer's constructor.
Definition: MixerOptions.h:51