This commit is contained in:
cfif 2025-06-02 13:26:40 +03:00
commit 494f767c2b
3 changed files with 100 additions and 0 deletions

View File

@ -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

View File

@ -0,0 +1,27 @@
//
// Created by zemon on 29.11.22.
//
#include <SystemDelayInterface.h>
#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;
}

12
modular.json Normal file
View File

@ -0,0 +1,12 @@
{
"dep": [
],
"cmake": {
"inc_dirs": [
"Inc"
],
"srcs": [
"Src/**.c"
]
}
}