1/**
2 * Copyright (c) 2006-2023 LOVE Development Team
3 *
4 * This software is provided 'as-is', without any express or implied
5 * warranty. In no event will the authors be held liable for any damages
6 * arising from the use of this software.
7 *
8 * Permission is granted to anyone to use this software for any purpose,
9 * including commercial applications, and to alter it and redistribute it
10 * freely, subject to the following restrictions:
11 *
12 * 1. The origin of this software must not be misrepresented; you must not
13 * claim that you wrote the original software. If you use this software
14 * in a product, an acknowledgment in the product documentation would be
15 * appreciated but is not required.
16 * 2. Altered source versions must be plainly marked as such, and must not be
17 * misrepresented as being the original software.
18 * 3. This notice may not be removed or altered from any source distribution.
19 **/
20
21#ifndef LOVE_AUDIO_RECORDING_DEVICE_H
22#define LOVE_AUDIO_RECORDING_DEVICE_H
23
24#include "common/Object.h"
25#include "sound/SoundData.h"
26
27#include <string>
28
29namespace love
30{
31namespace audio
32{
33
34class RecordingDevice : public love::Object
35{
36public:
37
38 static love::Type type;
39
40 static const int DEFAULT_SAMPLES = 8192;
41 static const int DEFAULT_SAMPLE_RATE = 8000;
42 static const int DEFAULT_BIT_DEPTH = 16;
43 static const int DEFAULT_CHANNELS = 1;
44
45 RecordingDevice();
46 virtual ~RecordingDevice();
47
48 /**
49 * Begins audio input recording process.
50 * @param samples Number of samples to buffer.
51 * @param sampleRate Desired sample rate.
52 * @param bitDepth Desired bit depth (8 or 16).
53 * @param channels Desired number of channels.
54 * @return True if recording started successfully.
55 **/
56 virtual bool start(int samples, int sampleRate, int bitDepth, int channels) = 0;
57
58 /**
59 * Stops audio input recording.
60 **/
61 virtual void stop() = 0;
62
63 /**
64 * Retreives recorded data.
65 * @return SoundData containing data obtained from recording device.
66 **/
67 virtual love::sound::SoundData *getData() = 0;
68
69 /**
70 * @return C string device name.
71 **/
72 virtual const char *getName() const = 0;
73
74 /**
75 * @return Number of samples currently recorded.
76 **/
77 virtual int getSampleCount() const = 0;
78
79 /**
80 * Gets the maximum number of samples that will be buffered, as set by start().
81 **/
82 virtual int getMaxSamples() const = 0;
83
84 /**
85 * @return Sample rate for recording.
86 **/
87 virtual int getSampleRate() const = 0;
88
89 /**
90 * @return Bit depth for recording.
91 **/
92 virtual int getBitDepth() const = 0;
93
94 /**
95 * @return Number of channels for recording.
96 **/
97 virtual int getChannelCount() const = 0;
98
99 /**
100 * @return True if currently recording.
101 **/
102 virtual bool isRecording() const = 0;
103
104}; //RecordingDevice
105
106} //audio
107} //love
108
109#endif //LOVE_AUDIO_RECORDING_DEVICE_H
110