-
Notifications
You must be signed in to change notification settings - Fork 622
Expand file tree
/
Copy pathDJEngine.h
More file actions
68 lines (53 loc) · 1.89 KB
/
Copy pathDJEngine.h
File metadata and controls
68 lines (53 loc) · 1.89 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* Copyright 2026 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OBOEDJ_DJENGINE_H
#define OBOEDJ_DJENGINE_H
#include <oboe/Oboe.h>
#include <vector>
#include <memory>
#include <atomic>
#include <mutex>
// iolib/parselib includes
#include <player/SampleBuffer.h>
#include <stream/MemInputStream.h>
#include <wav/WavStreamReader.h>
#include "Deck.h"
namespace oboedj {
class DJEngine : public oboe::AudioStreamDataCallback {
public:
DJEngine();
virtual ~DJEngine();
bool openStream();
bool startStream();
void stopStream();
void loadTrack(uint8_t* buffer, int32_t length, int32_t deckIndex);
void setDeckSpeed(int32_t deckIndex, float speed);
void setDeckPlaying(int32_t deckIndex, bool isPlaying);
void setCrossfader(float position); // 0.0 (Left) to 1.0 (Right)
// From AudioStreamDataCallback
oboe::DataCallbackResult onAudioReady(oboe::AudioStream *oboeStream,
void *audioData,
int32_t numFrames) override;
private:
std::shared_ptr<oboe::AudioStream> mStream;
std::vector<std::shared_ptr<Deck>> mDecks;
std::atomic<float> mCrossfader; // 0.0 to 1.0
int32_t mChannelCount;
int32_t mSampleRate;
std::mutex mLock; // Protect stream operations
};
} // namespace oboedj
#endif // OBOEDJ_DJENGINE_H