Skip to content

Commit

Permalink
Improve javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
fgnm committed Jul 24, 2024
1 parent 39a737e commit ef95994
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/main/java/games/rednblack/miniaudio/MAAudioBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,13 @@ public void write(float[] data, int size) {
public void dispose() {
miniAudio.disposeAudioBuffer(address, dataBufferAddress);
}

/**
* Get the length of the buffer in PCM frames.
*
* @return max length of the buffer
*/
public int getBufferSize() {
return bufferSize;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package games.rednblack.miniaudio;

/**
* Listener to get notified when the device change its state.
*
* NOTE: listener is called on MiniAudio's thread.
*
* @author fgnm
*/
public interface MADeviceNotificationListener {
void onNotification(MADeviceNotificationType type);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package games.rednblack.miniaudio;

/**
* Wrapper enum to map native MiniAudio device's notifications.
*
* @author fgnm
*/
public enum MADeviceNotificationType {
STARTED(0),
STOPPED(1),
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/games/rednblack/miniaudio/MiniAudio.java
Original file line number Diff line number Diff line change
Expand Up @@ -2083,6 +2083,15 @@ public void on_native_notification(int type) {
}
}

/**
* Decode a bytes array into a {@link MAAudioBuffer} using MiniAudio's decoder, useful when there's no direct access
* to files.
*
* @param data bytes array input data
* @param outputSize size of the decoded PCM frames
* @param outputChannels how many channels (usually 2)
* @return {@link MAAudioBuffer} with decoded data inside
*/
public MAAudioBuffer decodeBytes(byte[] data, int outputSize, int outputChannels) {
long dataBuffer = jniCreateFloatBuffer(outputSize * outputChannels);
int decodedFrames = jniDecodeBytes(data, data.length, dataBuffer, outputSize, outputChannels);
Expand Down
3 changes: 3 additions & 0 deletions testApp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,7 @@ task dist(type: Jar) {
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
dependsOn configurations.runtimeClasspath
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
manifest {
attributes 'Main-Class': "games.rednblack.miniaudio.Main"
}
}
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 @@ -119,7 +119,7 @@ public void onNotification(MADeviceNotificationType type) {
assetManager.getLogger().setLevel(Logger.DEBUG);
assetManager.setLoader(MASound.class, new MASoundLoader(miniAudio, assetManager.getFileHandleResolver()));
//assetManager.load("game.ogg", MASound.class);
assetManager.load("Median_test.ogg", MASound.class);
//assetManager.load("Median_test.ogg", MASound.class);
//assetManager.load("Perfect_Mishap.ogg", MASound.class);
//assetManager.load("piano2.wav", MASound.class);
}
Expand Down

0 comments on commit ef95994

Please sign in to comment.