From 494f767c2bf2cf822e947b8dd35e6fe01b96cb64 Mon Sep 17 00:00:00 2001 From: cfif Date: Mon, 2 Jun 2025 13:26:40 +0300 Subject: [PATCH] Init --- Inc/AudioRecorderInterface.h | 61 ++++++++++++++++++++++++++++++++++++ Src/AudioRecorderInterface.c | 27 ++++++++++++++++ modular.json | 12 +++++++ 3 files changed, 100 insertions(+) create mode 100644 Inc/AudioRecorderInterface.h create mode 100644 Src/AudioRecorderInterface.c create mode 100644 modular.json diff --git a/Inc/AudioRecorderInterface.h b/Inc/AudioRecorderInterface.h new file mode 100644 index 0000000..b138c18 --- /dev/null +++ b/Inc/AudioRecorderInterface.h @@ -0,0 +1,61 @@ +// +// Created by zemon on 29.11.22. +// + +#ifndef UVEOS_ON_NATION_AUDIORECORDERINTERFACE_H +#define UVEOS_ON_NATION_AUDIORECORDERINTERFACE_H + +#include "stdint.h" +#include "stddef.h" +#include "stdbool.h" + +typedef bool (*audioRecordStart)(void *env, char *sampleName, uint16_t sampleNameLength); +typedef bool (*audioRecordStop)(void *env, uint32_t timeout); +typedef bool (*audioRecordStopToEnd)(void *env, uint32_t timeout); +typedef bool (*audioRecordStartToEnd)(void *env, char *sampleName, uint16_t sampleNameLength); +typedef bool (*audioRecordDel)(void *env, char *name, uint16_t nameLen); +typedef bool (*audioRecordWaitStop)(void *env, uint32_t timeout); +typedef bool (*audioRecordIsBusy)(void *env, uint32_t timeout); + +typedef struct { + void *env; + audioRecordStart start; + audioRecordStartToEnd recordToEnd; + audioRecordStop stop; + audioRecordStopToEnd stopToEnd; + audioRecordDel del; + audioRecordIsBusy IsBusy; + audioRecordWaitStop waitStop; +} tAudioRecorderInterface; + +bool AudioRecordInterfaceRec(tAudioRecorderInterface *env, char *sampleName, uint16_t snLength); +bool AudioRecordInterfaceRecToEnd(tAudioRecorderInterface *env, char *sampleName, uint16_t snLength); +bool AudioRecordInterfaceStopToEnd(tAudioRecorderInterface *env, uint32_t timeout); + +#define AudioRecord_RecToEnd(RECORDER, NAME, LEN) AudioRecordInterfaceRecToEnd(RECORDER,NAME,LEN) +#define AudioRecord_Rec(RECORDER, NAME, LEN) AudioRecordInterfaceRec(RECORDER,NAME,LEN) +#define AudioRecord_StopToEndRec(RECORDER, TIMEOUT) AudioRecordInterfaceStopToEnd(RECORDER,TIMEOUT) + +#define AudioRecord_Start(RECORDER, NAME, LEN) RECORDER->start((RECORDER)->env,NAME,LEN) +#define AudioRecord_StartToEnd(RECORDER, NAME, LEN) RECORDER->recordToEnd((RECORDER)->env,NAME,LEN) +#define AudioRecord_WaitStop(RECORDER, TIMEOUT) RECORDER->waitStop((RECORDER)->env,TIMEOUT) +#define AudioRecord_WaitStopToEnd(RECORDER, TIMEOUT) RECORDER->stopToEnd((RECORDER)->env,TIMEOUT) +#define AudioRecord_Del(RECORDER, NAME, LEN) RECORDER->del((RECORDER)->env,NAME,LEN) +#define AudioRecord_IsBusy(RECORDER, TIMEOUT) RECORDER->IsBusy((RECORDER)->env,TIMEOUT) +#define AudioRecord_Stop(RECORDER, TIMEOUT) RECORDER->stop((RECORDER)->env,TIMEOUT) + + +#define AudioRecord_RecStaticToWaitEnd(RECORDER, NAME, TIMEOUT) \ + AudioRecord_Del(RECORDER,NAME,sizeof(NAME)-1); \ + AudioRecord_RecToEnd(RECORDER,NAME,sizeof(NAME)-1); \ + AudioRecord_StopToEndRec(RECORDER,TIMEOUT) + + +#define AudioRecord_RecStatic(RECORDER, NAME, TIMEOUT) \ + AudioRecord_Del(RECORDER,NAME,sizeof(NAME)-1); \ + AudioRecord_Rec(RECORDER,NAME,sizeof(NAME)-1); \ + AudioRecord_WaitStop(RECORDER,TIMEOUT) + +#endif //UVEOS_ON_NATION_AUDIORECORDERINTERFACE_H + + diff --git a/Src/AudioRecorderInterface.c b/Src/AudioRecorderInterface.c new file mode 100644 index 0000000..62ac949 --- /dev/null +++ b/Src/AudioRecorderInterface.c @@ -0,0 +1,27 @@ +// +// Created by zemon on 29.11.22. +// + +#include +#include "AudioRecorderInterface.h" + +bool AudioRecordInterfaceRecToEnd(tAudioRecorderInterface *env, char *sampleName, uint16_t snLength) { + if (!AudioRecord_StartToEnd(env, sampleName, snLength) ){ + return false; + } + return true; +} + +bool AudioRecordInterfaceStopToEnd(tAudioRecorderInterface *env, uint32_t timeout) { + if (!AudioRecord_WaitStopToEnd(env, timeout) ){ + return false; + } + return true; +} + +bool AudioRecordInterfaceRec(tAudioRecorderInterface *env, char *sampleName, uint16_t snLength) { + if (!AudioRecord_Start(env, sampleName, snLength) ){ + return false; + } + return true; +} diff --git a/modular.json b/modular.json new file mode 100644 index 0000000..d4d574e --- /dev/null +++ b/modular.json @@ -0,0 +1,12 @@ +{ + "dep": [ + ], + "cmake": { + "inc_dirs": [ + "Inc" + ], + "srcs": [ + "Src/**.c" + ] + } +} \ No newline at end of file