Skip to content

Commit 2fce32d

Browse files
authored
Moved simple methods of GOSoundOrganEngine from .cpp to .h (#2448)
1 parent 75a9bac commit 2fce32d

File tree

2 files changed

+19
-51
lines changed

2 files changed

+19
-51
lines changed

src/grandorgue/sound/GOSoundOrganEngine.cpp

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -92,33 +92,11 @@ void GOSoundOrganEngine::SetVolume(int volume) {
9292
m_Gain = powf(10.0f, m_Volume * 0.05f);
9393
}
9494

95-
float GOSoundOrganEngine::GetGain() { return m_Gain; }
96-
97-
void GOSoundOrganEngine::SetSamplesPerBuffer(unsigned samples_per_buffer) {
98-
m_SamplesPerBuffer = samples_per_buffer;
99-
}
100-
101-
void GOSoundOrganEngine::SetSampleRate(unsigned sample_rate) {
102-
m_SampleRate = sample_rate;
103-
}
104-
105-
void GOSoundOrganEngine::SetInterpolationType(unsigned type) {
106-
m_interpolation = (GOSoundResample::InterpolationType)type;
107-
}
108-
10995
void GOSoundOrganEngine::SetHardPolyphony(unsigned polyphony) {
11096
m_SamplerPool.SetUsageLimit(polyphony);
11197
m_PolyphonySoftLimit = (m_SamplerPool.GetUsageLimit() * 3) / 4;
11298
}
11399

114-
void GOSoundOrganEngine::SetPolyphonyLimiting(bool limiting) {
115-
m_PolyphonyLimiting = limiting;
116-
}
117-
118-
unsigned GOSoundOrganEngine::GetHardPolyphony() const {
119-
return m_SamplerPool.GetUsageLimit();
120-
}
121-
122100
void GOSoundOrganEngine::SetAudioGroupCount(unsigned groups) {
123101
if (groups < 1)
124102
groups = 1;
@@ -129,19 +107,7 @@ void GOSoundOrganEngine::SetAudioGroupCount(unsigned groups) {
129107
new GOSoundGroupTask(*this, m_SamplesPerBuffer));
130108
}
131109

132-
unsigned GOSoundOrganEngine::GetAudioGroupCount() { return m_AudioGroupCount; }
133-
134-
int GOSoundOrganEngine::GetVolume() const { return m_Volume; }
135-
136-
void GOSoundOrganEngine::SetScaledReleases(bool enable) {
137-
m_ScaledReleases = enable;
138-
}
139-
140-
void GOSoundOrganEngine::SetRandomizeSpeaking(bool enable) {
141-
m_RandomizeSpeaking = enable;
142-
}
143-
144-
float GOSoundOrganEngine::GetRandomFactor() {
110+
float GOSoundOrganEngine::GetRandomFactor() const {
145111
if (m_RandomizeSpeaking) {
146112
const double factor = (pow(2, 1.0 / 1200.0) - 1) / (RAND_MAX / 2);
147113
int num = rand() - RAND_MAX / 2;
@@ -277,8 +243,6 @@ void GOSoundOrganEngine::ReturnSampler(GOSoundSampler *sampler) {
277243
m_SamplerPool.ReturnSampler(sampler);
278244
}
279245

280-
GOSoundScheduler &GOSoundOrganEngine::GetScheduler() { return m_Scheduler; }
281-
282246
void GOSoundOrganEngine::SetAudioOutput(
283247
std::vector<GOAudioOutputConfiguration> audio_outputs) {
284248
m_AudioOutputTasks.clear();
@@ -348,7 +312,7 @@ void GOSoundOrganEngine::SetupReverb(GOConfig &settings) {
348312
}
349313

350314
unsigned GOSoundOrganEngine::GetBufferSizeFor(
351-
unsigned outputIndex, unsigned nFrames) {
315+
unsigned outputIndex, unsigned nFrames) const {
352316
return sizeof(float) * nFrames
353317
* m_AudioOutputTasks[outputIndex + 1]->GetNChannels();
354318
}

src/grandorgue/sound/GOSoundOrganEngine.h

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ class GOSoundOrganEngine : public GOSoundOrganInterface {
117117
* @param pSampler current playing sampler for switching to a new attack
118118
*/
119119
void SwitchToAnotherAttack(GOSoundSampler *pSampler);
120-
float GetRandomFactor();
121-
unsigned GetBufferSizeFor(unsigned outputIndex, unsigned n_frames);
120+
float GetRandomFactor() const;
121+
unsigned GetBufferSizeFor(unsigned outputIndex, unsigned n_frames) const;
122122

123123
public:
124124
GOSoundOrganEngine();
@@ -132,18 +132,22 @@ class GOSoundOrganEngine : public GOSoundOrganInterface {
132132
void SetAudioOutput(std::vector<GOAudioOutputConfiguration> audio_outputs);
133133
void SetupReverb(GOConfig &settings);
134134
void SetVolume(int volume);
135-
void SetSampleRate(unsigned sample_rate);
136-
void SetSamplesPerBuffer(unsigned sample_per_buffer);
137-
void SetInterpolationType(unsigned type);
135+
void SetSampleRate(unsigned sample_rate) { m_SampleRate = sample_rate; }
136+
void SetSamplesPerBuffer(unsigned sample_per_buffer) {
137+
m_SamplesPerBuffer = sample_per_buffer;
138+
}
139+
void SetInterpolationType(unsigned type) {
140+
m_interpolation = (GOSoundResample::InterpolationType)type;
141+
}
138142
unsigned GetSampleRate() const override { return m_SampleRate; }
139143
void SetAudioGroupCount(unsigned groups);
140-
unsigned GetAudioGroupCount();
144+
unsigned GetAudioGroupCount() const { return m_AudioGroupCount; }
141145
void SetHardPolyphony(unsigned polyphony);
142-
void SetPolyphonyLimiting(bool limiting);
143-
unsigned GetHardPolyphony() const;
144-
int GetVolume() const;
145-
void SetScaledReleases(bool enable);
146-
void SetRandomizeSpeaking(bool enable);
146+
void SetPolyphonyLimiting(bool limiting) { m_PolyphonyLimiting = limiting; }
147+
unsigned GetHardPolyphony() const { return m_SamplerPool.GetUsageLimit(); }
148+
int GetVolume() const { return m_Volume; }
149+
void SetScaledReleases(bool enable) { m_ScaledReleases = enable; }
150+
void SetRandomizeSpeaking(bool enable) { m_RandomizeSpeaking = enable; }
147151
const std::vector<double> &GetMeterInfo();
148152
void SetAudioRecorder(GOSoundRecorder *recorder, bool downmix);
149153

@@ -187,14 +191,14 @@ class GOSoundOrganEngine : public GOSoundOrganInterface {
187191
void GetAudioOutput(
188192
unsigned outputIndex, bool isLast, GOSoundBufferMutable &outBuffer);
189193
void NextPeriod();
190-
GOSoundScheduler &GetScheduler();
194+
GOSoundScheduler &GetScheduler() { return m_Scheduler; }
191195

192196
bool ProcessSampler(
193197
float *buffer, GOSoundSampler *sampler, unsigned n_frames, float volume);
194198
void ProcessRelease(GOSoundSampler *sampler);
195199
void PassSampler(GOSoundSampler *sampler);
196200
void ReturnSampler(GOSoundSampler *sampler);
197-
float GetGain();
201+
float GetGain() const { return m_Gain; }
198202
uint64_t GetTime() const { return m_CurrentTime; }
199203
};
200204

0 commit comments

Comments
 (0)