Skip to content

Commit

Permalink
Merge pull request #6 from Hotshot5000/added-listenerSetVelocity
Browse files Browse the repository at this point in the history
Added setListenerVelocity()
  • Loading branch information
fgnm committed Apr 8, 2024
2 parents 3e082f5 + 1867e10 commit 8d57a2d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/main/java/games/rednblack/miniaudio/MiniAudio.java
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,28 @@ public void setListenerWorldUp(int listenerIndex, float x, float y, float z) {
ma_engine_listener_set_world_up(&engine, listenerIndex, x, y, z);
*/

public void setListenerVelocity(float x, float y, float z) {
setListenerVelocity(0, x, y, z);
}

/**
* The listener's velocity vector can also be specified to be used with spatialization
* for the Doppler effect.
* Default 0, 0, 0.
*
* @param listenerIndex index of the listener
* @param x velocity
* @param y velocity
* @param z velocity
*/
public void setListenerVelocity(int listenerIndex, float x, float y, float z) {
jniSetListenerWorldUp(listenerIndex, x, y, z);
}

private native void jniSetListenerVelocity(int listenerIndex, float x, float y, float z);/*
ma_engine_listener_set_velocity(&engine, listenerIndex, x, y, z);
*/

/**
* The engine supports directional attenuation. The listener can have a cone the controls how sound is
* attenuated based on the listener's direction. When a sound is between the inner and outer cones, it
Expand Down
2 changes: 1 addition & 1 deletion testApp/src/main/java/games/rednblack/miniaudio/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static void main(String[] args) {
@Override
public void create() {
//miniAudio = new MiniAudio(1, 1, 0, 256, 44100);
miniAudio = new MiniAudio(null, false);
miniAudio = new MiniAudio();
miniAudio.setDeviceNotificationListener(new MADeviceNotificationListener() {
@Override
public void onNotification(MADeviceNotificationType type) {
Expand Down

0 comments on commit 8d57a2d

Please sign in to comment.