-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from software-mansion-labs/feat/android/panner…
…-node Feat/android/panner node
- Loading branch information
Showing
26 changed files
with
304 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include "StereoPannerNode.h" | ||
|
||
namespace audiocontext{ | ||
|
||
using namespace facebook::jni; | ||
|
||
double StereoPannerNode::getPan(){ | ||
static const auto method = javaClassLocal()->getMethod<jdouble()>("getPan"); | ||
return method(javaObject_.get()); | ||
} | ||
|
||
void StereoPannerNode::setPan(double pan){ | ||
static const auto method = javaClassLocal()->getMethod<void(jdouble)>("setPan"); | ||
method(javaObject_.get(), pan); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
|
||
#include <fbjni/fbjni.h> | ||
#include <react/jni/CxxModuleWrapper.h> | ||
#include <react/jni/JMessageQueueThread.h> | ||
#include <memory> | ||
#include "AudioNode.h" | ||
|
||
namespace audiocontext { | ||
|
||
using namespace facebook; | ||
using namespace facebook::jni; | ||
|
||
class StereoPannerNode : public jni::HybridClass<StereoPannerNode, AudioNode> { | ||
public: | ||
static auto constexpr kJavaDescriptor = "Lcom/audiocontext/nodes/StereoPannerNode;"; | ||
|
||
double getPan(); | ||
|
||
void setPan(double pan); | ||
}; | ||
|
||
} // namespace audiocontext |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
android/src/main/java/com/audiocontext/nodes/PlaybackParameters.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.audiocontext.nodes | ||
|
||
import android.media.AudioTrack | ||
|
||
class PlaybackParameters(val audioTrack: AudioTrack, var buffer: ShortArray) { | ||
var leftPan = 1.0 | ||
var rightPan = 1.0 | ||
var gain = 1.0 | ||
} |
23 changes: 23 additions & 0 deletions
23
android/src/main/java/com/audiocontext/nodes/StereoPannerNode.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.audiocontext.nodes | ||
|
||
import com.audiocontext.context.BaseAudioContext | ||
import com.facebook.jni.HybridData | ||
import kotlin.math.min | ||
|
||
class StereoPannerNode(context: BaseAudioContext): AudioNode(context) { | ||
override val numberOfInputs: Int = 1 | ||
override val numberOfOutputs: Int = 1 | ||
private var pan: Double = 0.0 | ||
get() = field | ||
set(value) { | ||
field = value | ||
} | ||
|
||
private val mHybridData: HybridData? = initHybrid(); | ||
|
||
override fun process(playbackParameters: PlaybackParameters) { | ||
playbackParameters.leftPan = min(1.0 - pan, 1.0) | ||
playbackParameters.rightPan = min(1.0 + pan, 1.0) | ||
super.process(playbackParameters) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.