aboutsummaryrefslogtreecommitdiff
path: root/externals/oboe/samples/iolib/src/main/cpp/player/SampleSource.h
diff options
context:
space:
mode:
authorcrueter <crueter@eden-emu.dev>2025-08-04 04:50:14 +0200
committercrueter <crueter@eden-emu.dev>2025-08-04 04:50:14 +0200
commit51b170b470ed587f99a7c2a773e4464687f0d07a (patch)
tree4c03c510cfb17a5f5d6233df490d78f06dcfa7f7 /externals/oboe/samples/iolib/src/main/cpp/player/SampleSource.h
parent04e5e6453875ffa5c79cdb421a29bc19985b1049 (diff)
[cmake] refactor: Use CPM over submodules (#143)
Transfers the majority of submodules and large externals to CPM, using source archives rather than full Git clones. Not only does this save massive amounts of clone and configure time, but dependencies are grabbed on-demand rather than being required by default. Additionally, CPM will (generally) automatically search for system dependencies, though certain dependencies have options to control this. Testing shows gains ranging from 5x to 10x in terms of overall clone/configure time. Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/143 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
Diffstat (limited to 'externals/oboe/samples/iolib/src/main/cpp/player/SampleSource.h')
-rw-r--r--externals/oboe/samples/iolib/src/main/cpp/player/SampleSource.h106
1 files changed, 0 insertions, 106 deletions
diff --git a/externals/oboe/samples/iolib/src/main/cpp/player/SampleSource.h b/externals/oboe/samples/iolib/src/main/cpp/player/SampleSource.h
deleted file mode 100644
index 54edbf1f9b..0000000000
--- a/externals/oboe/samples/iolib/src/main/cpp/player/SampleSource.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2020 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 _PLAYER_SAMPLESOURCE_
-#define _PLAYER_SAMPLESOURCE_
-
-#include <cstdint>
-
-#include "DataSource.h"
-
-#include "SampleBuffer.h"
-
-namespace iolib {
-
-/**
- * Defines an interface for audio data provided to a player object.
- * Concrete examples include OneShotSampleBuffer. One could imagine a LoopingSampleBuffer.
- * Supports stereo position via mPan member.
- */
-class SampleSource: public DataSource {
-public:
- // Pan position of the audio in a stereo mix
- // [left:-1.0f] <- [center: 0.0f] -> -[right: 1.0f]
- static constexpr float PAN_HARDLEFT = -1.0f;
- static constexpr float PAN_HARDRIGHT = 1.0f;
- static constexpr float PAN_CENTER = 0.0f;
-
- SampleSource(SampleBuffer *sampleBuffer, float pan)
- : mSampleBuffer(sampleBuffer), mCurSampleIndex(0), mIsPlaying(false), mIsLoopMode(false), mGain(1.0f) {
- setPan(pan);
- }
- virtual ~SampleSource() {}
-
- void setPlayMode() { mCurSampleIndex = 0; mIsPlaying = true; }
- void setStopMode() { mIsPlaying = false; mCurSampleIndex = 0; }
-
- void setLoopMode(bool isLoopMode) { mIsLoopMode = isLoopMode; }
-
- bool isPlaying() { return mIsPlaying; }
-
- void setPan(float pan) {
- if (pan < PAN_HARDLEFT) {
- mPan = PAN_HARDLEFT;
- } else if (pan > PAN_HARDRIGHT) {
- mPan = PAN_HARDRIGHT;
- } else {
- mPan = pan;
- }
- calcGainFactors();
- }
-
- float getPan() {
- return mPan;
- }
-
- void setGain(float gain) {
- mGain = gain;
- calcGainFactors();
- }
-
- float getGain() {
- return mGain;
- }
-
-protected:
- SampleBuffer *mSampleBuffer;
-
- int32_t mCurSampleIndex;
-
- bool mIsPlaying;
- std::atomic<bool> mIsLoopMode;
-
- // Logical pan value
- float mPan;
-
- // precomputed channel gains for pan
- float mLeftGain;
- float mRightGain;
-
- // Overall gain
- float mGain;
-
-private:
- void calcGainFactors() {
- // useful panning information: http://www.cs.cmu.edu/~music/icm-online/readings/panlaws/
- float rightPan = (mPan * 0.5) + 0.5;
- mRightGain = rightPan * mGain;
- mLeftGain = (1.0 - rightPan) * mGain; }
-};
-
-} // namespace wavlib
-
-#endif //_PLAYER_SAMPLESOURCE_