Skip to content

Commit

Permalink
FEAT: possibility to specify number of channels for playback
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Sep 20, 2023
1 parent 1374aeb commit 8ab3a54
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ Retrive playback/capture device names
Initialize a playback device
* `index` `[integer!]`
* `/pause` Don't start it automatically
* `/channels` The number of channels to use for playback
* `number` `[integer!]` When set to 0 the device's native channel count will be used

#### `load` `:sound`
Loads a file and returns sound's handle
Expand Down
2 changes: 1 addition & 1 deletion src/miniaudio-commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ COMMAND cmd_init_playback(RXIFRM *frm, void *ctx) {
deviceConfig = ma_device_config_init(ma_device_type_playback);
deviceConfig.playback.pDeviceID = &pPlaybackDeviceInfos[iChosenDevice].id;
deviceConfig.playback.format = gResourceManager.config.decodedFormat;
deviceConfig.playback.channels = 0;
deviceConfig.playback.channels = RXA_INT64(frm, 4);
deviceConfig.sampleRate = gResourceManager.config.decodedSampleRate;
deviceConfig.dataCallback = data_callback;
deviceConfig.pUserData = engine;
Expand Down
2 changes: 1 addition & 1 deletion src/miniaudio-rebol-extension.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ typedef int (*MyCommandPointer)(RXIFRM *frm, void *ctx);
"REBOL [Title: {Rebol MiniAudio Extension} Type: module Version: 0.11.18.1]\n"\
"init-words: command [args [block!] type [block!]]\n"\
"get-devices: command [\"Retrive playback/capture device names\"]\n"\
"init-playback: command [\"Initialize a playback device\" index [integer!] /pause \"Don't start it automatically\"]\n"\
"init-playback: command [\"Initialize a playback device\" index [integer!] /pause \"Don't start it automatically\" /channels \"The number of channels to use for playback\" number [integer!] {When set to 0 the device's native channel count will be used}]\n"\
"load: command [\"Loads a file and returns sound's handle\" sound [file!]]\n"\
"play: command [{Loads a file (if not already loaded) and starts playing it. Returns a sound handle.} sound [file! handle!] \"Source file or a ma-sound handle\" /stream \"Do not load the entire sound into memory\" /loop \"Turn looping on\" /volume vol [percent! decimal!] /fade in [integer! time!] \"PCM frames or time\"]\n"\
"pause: command [\"Pause sound playback\" sound [handle!]]\n"\
Expand Down
8 changes: 7 additions & 1 deletion src/miniaudio-rebol-extension.r3
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ commands: [
;test: ["..."]

get-devices: ["Retrive playback/capture device names"]
init-playback: ["Initialize a playback device" index [integer!] /pause "Don't start it automatically"]
init-playback: [
"Initialize a playback device"
index [integer!]
/pause "Don't start it automatically"
/channels "The number of channels to use for playback"
number [integer!] "When set to 0 the device's native channel count will be used"
]



Expand Down

0 comments on commit 8ab3a54

Please sign in to comment.