From a00949d3f8b8bb220e912e321f952138e4a4a624 Mon Sep 17 00:00:00 2001 From: mgrojo Date: Wed, 4 Sep 2024 20:34:24 +0200 Subject: [PATCH] Add sfSoundBufferRecorder_[gs]etChannelCount This requires CSFML version with this change included: https://github.com/SFML/CSFML/pull/294 Added test I made for Rosetta including the new setChannelCount and getChannelCount functions. --- .../sf__audio__soundbufferrecorder___spec.js | 389 +++++++++++ doc/entities/subprograms.js | 14 + doc/index.js | 2 +- doc/srcs/sf-audio-soundbufferrecorder.ads.js | 660 +++++++++++++++++- include/generated/gen.sh | 2 +- include/sf-audio-soundbufferrecorder.ads | 34 + tests/Makefile | 2 +- tests/sound/Makefile | 10 + tests/sound/main.adb | 43 ++ tests/sound/main.gpr | 12 + 10 files changed, 1163 insertions(+), 5 deletions(-) create mode 100644 tests/sound/Makefile create mode 100644 tests/sound/main.adb create mode 100644 tests/sound/main.gpr diff --git a/doc/docs/sf__audio__soundbufferrecorder___spec.js b/doc/docs/sf__audio__soundbufferrecorder___spec.js index 858e71b..f7101d6 100644 --- a/doc/docs/sf__audio__soundbufferrecorder___spec.js +++ b/doc/docs/sf__audio__soundbufferrecorder___spec.js @@ -415,6 +415,185 @@ GNATdoc.Documentation = { ] } }, + { + "label": "getChannelCount", + "qualifier": "", + "line": 151, + "column": 13, + "src": "srcs/sf-audio-soundbufferrecorder.ads.html", + "summary": [ + ], + "description": [ + { + "kind": "code", + "children": [ + { + "kind": "line", + "number": 151, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "keyword", + "text": "function" + }, + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "identifier", + "text": "getChannelCount", + "href": "docs/sf__audio__soundbufferrecorder___spec.html#L151C13" + }, + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "identifier", + "text": "(" + }, + { + "kind": "span", + "cssClass": "identifier", + "text": "soundBufferRecorder", + "href": "docs/sf__audio__soundbufferrecorder___spec.html#L151C30" + }, + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "identifier", + "text": ":" + }, + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "identifier", + "text": "sfSoundBufferRecorder_Ptr", + "href": "docs/sf__audio___spec.html#L41C9" + }, + { + "kind": "span", + "cssClass": "identifier", + "text": ")" + }, + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "keyword", + "text": "return" + }, + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "identifier", + "text": "sfUint32", + "href": "docs/sf___spec.html#L92C9" + }, + { + "kind": "span", + "cssClass": "identifier", + "text": ";" + } + ] + } + ] + }, + { + "kind": "paragraph", + "children": [ + { + "kind": "html", + "html": "", + "children": [ + ] + }, + { + "kind": "span", + "text": " Get the number of channels used by this recorder\n" + }, + { + "kind": "span", + "text": "Currently only mono and stereo are supported, so the\n" + }, + { + "kind": "span", + "text": "value is either 1 (for mono) or 2 (for stereo).\n" + } + ] + } + ], + "parameters": [ + { + "label": "soundBufferRecorder", + "line": 151, + "column": 30, + "type": { + "label": "Sf.Audio.sfSoundBufferRecorder_Ptr", + "docHref": "docs/sf__audio___spec.html#L41C9" + }, + "description": [ + { + "kind": "paragraph", + "children": [ + { + "kind": "span", + "text": "Sound buffer recorder object\n" + } + ] + } + ] + } + ], + "returns": { + "description": [ + { + "kind": "paragraph", + "children": [ + { + "kind": "span", + "text": "Number of channels\n" + }, + { + "kind": "html", + "html": "

See: ", + "children": [ + ] + }, + { + "kind": "span", + "text": " setChannelCount\n" + } + ] + } + ] + } + }, { "label": "getDevice", "qualifier": "", @@ -754,6 +933,216 @@ GNATdoc.Documentation = { ] } }, + { + "label": "setChannelCount", + "qualifier": "", + "line": 136, + "column": 14, + "src": "srcs/sf-audio-soundbufferrecorder.ads.html", + "summary": [ + ], + "description": [ + { + "kind": "code", + "children": [ + { + "kind": "line", + "number": 136, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "keyword", + "text": "procedure" + }, + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "identifier", + "text": "setChannelCount", + "href": "docs/sf__audio__soundbufferrecorder___spec.html#L136C14" + }, + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "identifier", + "text": "(" + }, + { + "kind": "span", + "cssClass": "identifier", + "text": "soundBufferRecorder", + "href": "docs/sf__audio__soundbufferrecorder___spec.html#L136C31" + }, + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "identifier", + "text": ":" + }, + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "identifier", + "text": "sfSoundBufferRecorder_Ptr", + "href": "docs/sf__audio___spec.html#L41C9" + }, + { + "kind": "span", + "cssClass": "identifier", + "text": ";" + }, + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "identifier", + "text": "channelCount", + "href": "docs/sf__audio__soundbufferrecorder___spec.html#L136C80" + }, + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "identifier", + "text": ":" + }, + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "identifier", + "text": "sfUint32", + "href": "docs/sf___spec.html#L92C9" + }, + { + "kind": "span", + "cssClass": "identifier", + "text": ")" + }, + { + "kind": "span", + "cssClass": "identifier", + "text": ";" + } + ] + } + ] + }, + { + "kind": "paragraph", + "children": [ + { + "kind": "html", + "html": "", + "children": [ + ] + }, + { + "kind": "span", + "text": " Set the channel count of the audio capture device\n" + }, + { + "kind": "span", + "text": "This method allows you to specify the number of channels\n" + }, + { + "kind": "span", + "text": "used for recording. Currently only 16-bit mono and\n" + }, + { + "kind": "span", + "text": "16-bit stereo are supported.\n" + } + ] + } + ], + "parameters": [ + { + "label": "soundBufferRecorder", + "line": 136, + "column": 31, + "type": { + "label": "Sf.Audio.sfSoundBufferRecorder_Ptr", + "docHref": "docs/sf__audio___spec.html#L41C9" + }, + "description": [ + { + "kind": "paragraph", + "children": [ + { + "kind": "span", + "text": "Sound buffer recorder object\n" + } + ] + } + ] + }, + { + "label": "channelCount", + "line": 136, + "column": 80, + "type": { + "label": "Sf.sfUint32", + "docHref": "docs/sf___spec.html#L92C9" + }, + "description": [ + { + "kind": "paragraph", + "children": [ + { + "kind": "span", + "text": "Number of channels. Currently only\n" + }, + { + "kind": "span", + "text": "mono (1) and stereo (2) are supported.\n" + }, + { + "kind": "html", + "html": "

See: ", + "children": [ + ] + }, + { + "kind": "span", + "text": " getChannelCount\n" + } + ] + } + ] + } + ] + }, { "label": "setDevice", "qualifier": "", diff --git a/doc/entities/subprograms.js b/doc/entities/subprograms.js index a65a8f6..6c8400e 100644 --- a/doc/entities/subprograms.js +++ b/doc/entities/subprograms.js @@ -1569,6 +1569,13 @@ GNATdoc.EntitiesCategory = { "declared_qualifier": "", "srcHref": "srcs/sf-audio-soundbuffer.ads.html#L177" }, + { + "label": "getChannelCount", + "docHref": "docs/sf__audio__soundbufferrecorder___spec.html#L151C13", + "declared": "Sf.Audio.SoundBufferRecorder", + "declared_qualifier": "", + "srcHref": "srcs/sf-audio-soundbufferrecorder.ads.html#L151" + }, { "label": "getChannelCount", "docHref": "docs/sf__audio__soundrecorder___spec.html#L211C13", @@ -7582,6 +7589,13 @@ GNATdoc.EntitiesCategory = { "declared_qualifier": "", "srcHref": "srcs/sf-graphics-view.ads.html#L70" }, + { + "label": "setChannelCount", + "docHref": "docs/sf__audio__soundbufferrecorder___spec.html#L136C14", + "declared": "Sf.Audio.SoundBufferRecorder", + "declared_qualifier": "", + "srcHref": "srcs/sf-audio-soundbufferrecorder.ads.html#L136" + }, { "label": "setChannelCount", "docHref": "docs/sf__audio__soundrecorder___spec.html#L197C14", diff --git a/doc/index.js b/doc/index.js index 7dfac06..d4226a4 100644 --- a/doc/index.js +++ b/doc/index.js @@ -1,4 +1,4 @@ GNATdoc.Index = { "project": "ASFML", - "timestamp": "2024-06-01 14:04:23" + "timestamp": "2024-09-04 18:25:32" }; \ No newline at end of file diff --git a/doc/srcs/sf-audio-soundbufferrecorder.ads.js b/doc/srcs/sf-audio-soundbufferrecorder.ads.js index fd72018..f0362b7 100644 --- a/doc/srcs/sf-audio-soundbufferrecorder.ads.js +++ b/doc/srcs/sf-audio-soundbufferrecorder.ads.js @@ -2340,6 +2340,662 @@ GNATdoc.SourceFile = { { "kind": "line", "number": 121, + "children": [ + ] + }, + { + "kind": "line", + "number": 122, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "comment", + "text": "--//////////////////////////////////////////////////////////" + } + ] + }, + { + "kind": "line", + "number": 123, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "comment", + "text": "--/ @brief Set the channel count of the audio capture device" + } + ] + }, + { + "kind": "line", + "number": 124, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "comment", + "text": "--/" + } + ] + }, + { + "kind": "line", + "number": 125, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "comment", + "text": "--/ This method allows you to specify the number of channels" + } + ] + }, + { + "kind": "line", + "number": 126, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "comment", + "text": "--/ used for recording. Currently only 16-bit mono and" + } + ] + }, + { + "kind": "line", + "number": 127, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "comment", + "text": "--/ 16-bit stereo are supported." + } + ] + }, + { + "kind": "line", + "number": 128, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "comment", + "text": "--/" + } + ] + }, + { + "kind": "line", + "number": 129, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "comment", + "text": "--/ @param soundBufferRecorder Sound buffer recorder object" + } + ] + }, + { + "kind": "line", + "number": 130, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "comment", + "text": "--/ @param channelCount Number of channels. Currently only" + } + ] + }, + { + "kind": "line", + "number": 131, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "comment", + "text": "--/ mono (1) and stereo (2) are supported." + } + ] + }, + { + "kind": "line", + "number": 132, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "comment", + "text": "--/" + } + ] + }, + { + "kind": "line", + "number": 133, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "comment", + "text": "--/ @see getChannelCount" + } + ] + }, + { + "kind": "line", + "number": 134, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "comment", + "text": "--/" + } + ] + }, + { + "kind": "line", + "number": 135, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "comment", + "text": "--//////////////////////////////////////////////////////////" + } + ] + }, + { + "kind": "line", + "number": 136, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "keyword", + "text": "procedure" + }, + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "identifier", + "text": "setChannelCount", + "href": "docs/sf__audio__soundbufferrecorder___spec.html#L136C14" + }, + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "identifier", + "text": "(" + }, + { + "kind": "span", + "cssClass": "identifier", + "text": "soundBufferRecorder", + "href": "docs/sf__audio__soundbufferrecorder___spec.html#L136C31" + }, + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "identifier", + "text": ":" + }, + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "identifier", + "text": "sfSoundBufferRecorder_Ptr", + "href": "docs/sf__audio___spec.html#L41C9" + }, + { + "kind": "span", + "cssClass": "identifier", + "text": ";" + }, + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "identifier", + "text": "channelCount", + "href": "docs/sf__audio__soundbufferrecorder___spec.html#L136C80" + }, + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "identifier", + "text": ":" + }, + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "identifier", + "text": "sfUint32", + "href": "docs/sf___spec.html#L92C9" + }, + { + "kind": "span", + "cssClass": "identifier", + "text": ")" + }, + { + "kind": "span", + "cssClass": "identifier", + "text": ";" + } + ] + }, + { + "kind": "line", + "number": 137, + "children": [ + ] + }, + { + "kind": "line", + "number": 138, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "comment", + "text": "--//////////////////////////////////////////////////////////" + } + ] + }, + { + "kind": "line", + "number": 139, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "comment", + "text": "--/ @brief Get the number of channels used by this recorder" + } + ] + }, + { + "kind": "line", + "number": 140, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "comment", + "text": "--/" + } + ] + }, + { + "kind": "line", + "number": 141, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "comment", + "text": "--/ Currently only mono and stereo are supported, so the" + } + ] + }, + { + "kind": "line", + "number": 142, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "comment", + "text": "--/ value is either 1 (for mono) or 2 (for stereo)." + } + ] + }, + { + "kind": "line", + "number": 143, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "comment", + "text": "--/" + } + ] + }, + { + "kind": "line", + "number": 144, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "comment", + "text": "--/ @param soundBufferRecorder Sound buffer recorder object" + } + ] + }, + { + "kind": "line", + "number": 145, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "comment", + "text": "--/" + } + ] + }, + { + "kind": "line", + "number": 146, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "comment", + "text": "--/ @return Number of channels" + } + ] + }, + { + "kind": "line", + "number": 147, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "comment", + "text": "--/" + } + ] + }, + { + "kind": "line", + "number": 148, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "comment", + "text": "--/ @see setChannelCount" + } + ] + }, + { + "kind": "line", + "number": 149, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "comment", + "text": "--/" + } + ] + }, + { + "kind": "line", + "number": 150, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "comment", + "text": "--//////////////////////////////////////////////////////////" + } + ] + }, + { + "kind": "line", + "number": 151, + "children": [ + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "keyword", + "text": "function" + }, + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "identifier", + "text": "getChannelCount", + "href": "docs/sf__audio__soundbufferrecorder___spec.html#L151C13" + }, + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "identifier", + "text": "(" + }, + { + "kind": "span", + "cssClass": "identifier", + "text": "soundBufferRecorder", + "href": "docs/sf__audio__soundbufferrecorder___spec.html#L151C30" + }, + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "identifier", + "text": ":" + }, + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "identifier", + "text": "sfSoundBufferRecorder_Ptr", + "href": "docs/sf__audio___spec.html#L41C9" + }, + { + "kind": "span", + "cssClass": "identifier", + "text": ")" + }, + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "keyword", + "text": "return" + }, + { + "kind": "span", + "cssClass": "text", + "text": " " + }, + { + "kind": "span", + "cssClass": "identifier", + "text": "sfUint32", + "href": "docs/sf___spec.html#L92C9" + }, + { + "kind": "span", + "cssClass": "identifier", + "text": ";" + } + ] + }, + { + "kind": "line", + "number": 152, + "children": [ + ] + }, + { + "kind": "line", + "number": 153, "children": [ { "kind": "span", @@ -2350,13 +3006,13 @@ GNATdoc.SourceFile = { }, { "kind": "line", - "number": 122, + "number": 154, "children": [ ] }, { "kind": "line", - "number": 131, + "number": 165, "children": [ { "kind": "span", diff --git a/include/generated/gen.sh b/include/generated/gen.sh index 82c3cc0..da86856 100755 --- a/include/generated/gen.sh +++ b/include/generated/gen.sh @@ -17,7 +17,7 @@ function PackageTofile CSFML_PREFIX=$1 -for file in ${CSFML_PREFIX}/include/SFML/*/*.h +for file in ${CSFML_PREFIX}/include/CSFML/*/*.h do PARENT_DIRNAME=$(dirname $(dirname $file)) GRANDPARENT_DIRNAME=$(dirname $PARENT_DIRNAME) diff --git a/include/sf-audio-soundbufferrecorder.ads b/include/sf-audio-soundbufferrecorder.ads index aeb7391..40edd51 100644 --- a/include/sf-audio-soundbufferrecorder.ads +++ b/include/sf-audio-soundbufferrecorder.ads @@ -118,6 +118,38 @@ package Sf.Audio.SoundBufferRecorder is function getDevice (soundBufferRecorder : sfSoundBufferRecorder_Ptr) return String; + + --////////////////////////////////////////////////////////// + --/ @brief Set the channel count of the audio capture device + --/ + --/ This method allows you to specify the number of channels + --/ used for recording. Currently only 16-bit mono and + --/ 16-bit stereo are supported. + --/ + --/ @param soundBufferRecorder Sound buffer recorder object + --/ @param channelCount Number of channels. Currently only + --/ mono (1) and stereo (2) are supported. + --/ + --/ @see getChannelCount + --/ + --////////////////////////////////////////////////////////// + procedure setChannelCount (soundBufferRecorder : sfSoundBufferRecorder_Ptr; channelCount : sfUint32); + + --////////////////////////////////////////////////////////// + --/ @brief Get the number of channels used by this recorder + --/ + --/ Currently only mono and stereo are supported, so the + --/ value is either 1 (for mono) or 2 (for stereo). + --/ + --/ @param soundBufferRecorder Sound buffer recorder object + --/ + --/ @return Number of channels + --/ + --/ @see setChannelCount + --/ + --////////////////////////////////////////////////////////// + function getChannelCount (soundBufferRecorder : sfSoundBufferRecorder_Ptr) return sfUint32; + private pragma Import (C, create, "sfSoundBufferRecorder_create"); @@ -126,6 +158,8 @@ private pragma Import (C, stop, "sfSoundBufferRecorder_stop"); pragma Import (C, getSampleRate, "sfSoundBufferRecorder_getSampleRate"); pragma Import (C, getBuffer, "sfSoundBufferRecorder_getBuffer"); + pragma Import (C, setChannelCount, "sfSoundBufferRecorder_setChannelCount"); + pragma Import (C, getChannelCount, "sfSoundBufferRecorder_getChannelCount"); end Sf.Audio.SoundBufferRecorder; diff --git a/tests/Makefile b/tests/Makefile index 632ed01..40cb1b0 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,4 +1,4 @@ -SUBDIRS:=clock example graphics music opengl pong renderwindow thread window vulkan ftp +SUBDIRS:=clock example graphics music opengl pong renderwindow thread window vulkan ftp sound .PHONY: all clean run diff --git a/tests/sound/Makefile b/tests/sound/Makefile new file mode 100644 index 0000000..6b98c28 --- /dev/null +++ b/tests/sound/Makefile @@ -0,0 +1,10 @@ +.PHONY: all clean run + +all: + gprbuild + +clean: + gprclean + +run: + ./main diff --git a/tests/sound/main.adb b/tests/sound/main.adb new file mode 100644 index 0000000..03993c9 --- /dev/null +++ b/tests/sound/main.adb @@ -0,0 +1,43 @@ +with Sf.Audio.SoundBufferRecorder; +with Sf.Audio.SoundBuffer; +with Ada.Text_IO; + +procedure Main is + use Sf, Sf.Audio, Ada.Text_IO; + Sound_Buffer_Recorder : constant sfSoundBufferRecorder_Ptr := + SoundBufferRecorder.create; + Sound_Buffer : sfSoundBuffer_Ptr; + Sound_File : constant String := "output.ogg"; +begin + + if Sound_Buffer_Recorder = null then + Put_Line (Standard_Error, "Error: sound recorder not available!"); + return; + end if; + + SoundBufferRecorder.setChannelCount (Sound_Buffer_Recorder, 2); + + -- By default the recording is in 16-bit mono. Using the + -- setChannelCount method you can change the number of channels + -- used by the audio capture device to record. + if SoundBufferRecorder.start (Sound_Buffer_Recorder, sampleRate => 44_100) /= sfTrue then + Put_Line (Standard_Error, "Error: sound recorder cannot start!"); + return; + end if; + + delay 10.0; + SoundBufferRecorder.stop (Sound_Buffer_Recorder); + + Sound_Buffer := SoundBufferRecorder.getBuffer (Sound_Buffer_Recorder); + if SoundBuffer.saveToFile (Sound_Buffer, filename => Sound_File) /= sfTrue then + Put_Line (Standard_Error, "Error: recorded sound could not be saved!"); + end if; + + Put_Line ("Saved sound in `" & Sound_File & "` with "); + Put_Line ("- Channel count: " & + SoundBufferRecorder.getChannelCount (Sound_Buffer_Recorder)'Image); + Put_Line ("- Sample rate: " & + SoundBufferRecorder.getSampleRate (Sound_Buffer_Recorder)'Image); + + SoundBufferRecorder.destroy (Sound_Buffer_Recorder); +end Main; diff --git a/tests/sound/main.gpr b/tests/sound/main.gpr new file mode 100644 index 0000000..c590600 --- /dev/null +++ b/tests/sound/main.gpr @@ -0,0 +1,12 @@ +with "../../asfml.gpr"; + +project Main is + + for Create_Missing_Dirs use "True"; + + for Source_Dirs use ("."); + for Object_Dir use "obj"; + for Main use ("main.adb"); + for Exec_Dir use "."; + +end Main; \ No newline at end of file