summaryrefslogtreecommitdiffstats
path: root/src/engine/engine.h
blob: 4516ac54500a349391b38140f21529b30eca528e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#pragma once

#include "audio/signalinfo.h"


namespace mixxx {
    // TODO(XXX): When we move from stereo to multi-channel this needs updating.
    static constexpr audio::ChannelCount kEngineChannelCount =
            audio::ChannelCount(2);

    // Contains the information needed to process a buffer of audio
    class EngineParameters {
      public:
        SINT framesPerBuffer() const {
            return m_framesPerBuffer;
        }
        SINT samplesPerBuffer() const {
            return m_outputSignal.frames2samples(framesPerBuffer());
        }

        audio::ChannelCount channelCount() const {
            return m_outputSignal.getChannelCount();
        }

        audio::SampleRate sampleRate() const {
            return m_outputSignal.getSampleRate();
        }

        explicit EngineParameters(
                audio::SampleRate sampleRate,
                SINT framesPerBuffer)
                : m_outputSignal(
                          kEngineChannelCount,
                          sampleRate),
                  m_framesPerBuffer(framesPerBuffer) {
            DEBUG_ASSERT(framesPerBuffer > 0);
        }

      private:
        const audio::SignalInfo m_outputSignal;
        const SINT m_framesPerBuffer;
    };
}