main.cpp,main.cfg: Added many new test calls.

This commit is contained in:
kevin 2021-08-15 16:08:17 -04:00
parent 3b3c8f3e2b
commit bc8d58d690
2 changed files with 266 additions and 31 deletions

View File

@ -174,13 +174,15 @@
audio_midi: {
audio_midi: {
record_dir: "/home/kevin/temp/audio_midi",
record_fn: "record",
record_dir: "/home/kevin/temp/audio_midi_app",
record_folder: "record",
record_fn_ext: "am",
max_midi_msg_count: 32768,
midi_timer_period_micro_sec: 15000,
midi_out_device: "Fastlane",
midi_out_port: "Fastlane MIDI A"
midi_out_port: "Fastlane MIDI A",
audio_in_ch_map: [0, 1 ],
audio_out_ch_map: [0, 1 ]
},
ui: {
@ -229,9 +231,9 @@
deviceL: [
{
// System device name
//device: "Scarlett 18i20 USB USB Audio",
device: "Scarlett 18i20 USB USB Audio",
//device: "USB Audio CODEC USB Audio",
device: "HDA Intel PCH CS4208 Analog",
//device: "HDA Intel PCH CS4208 Analog",
enableFl: true, // (req)
label: "main", // (req) User label
@ -300,7 +302,7 @@
afop:
{
sine: { fn:"~/temp/temp_sine_1000_hz.wav", srate: 48000, bits: 16, hz: 1000, gain: 0.5, secs: 10.0 },
sine: { fn:"~/temp/temp_sine_100_hz.wav", srate: 48000, bits: 0, hz: 100, gain: 0.5, secs: 10.0 },
},
mnist: {
@ -354,6 +356,17 @@
outCssFn: "~/temp/test_svg.css"
},
audio_mix:
{
test_label: audio_mix,
outFn: "~/temp/temp_mix.wav",
outBits: 0,
srcL: [
{ gain: 0.6, src:"~/temp/temp_sine_100_hz.wav" },
{ gain: 0.4, src:"~/temp/temp_sine_1000_hz.wav" } ]
},
audio_mix_a:
{
test_label: audio_mix,
@ -715,11 +728,195 @@
fft: {},
ifft: {},
convolve: {}
convolve: {},
audio_transforms: {},
am_to_midi_file: { inDir: "~/temp/audio_midi_app_backup/taka1" },
audio_file_proc: {
srcFn: "/home/kevin/temp/audio.wav",
dstFn: "/home/kevin/temp/audio_out.wav",
cfg: "tremelo",
recordChN: 0,
recorder: {
enableFl: true,
frameN: 1024,
sigN: 10,
filename: "~/temp/temp.csv",
colLabelL: [ "mean0", "mean1", "db0", "db1", "db2", "db3", "db4" ]
}
tremelo: {
wndSmpN: 1024,
hopSmpN: 1024,
program: "tremelo",
args: {
hz: 2.5,
depth: 0.75
}
}
pvoc: {
wndSmpN: 512,
hopSmpN: 512,
program: "pvoc",
args: {
procSmpN: 512,
wndSmpN: 2048,
hopSmpN: 512
}
}
}
pvoc_file_proc: {
srcFn: "/home/kevin/temp/audio.wav",
dstFn: "/home/kevin/temp/audio_out.wav",
program: "spec_dist",
recordChN: 2,
recorder: {
enableFl: false,
frameN: 1024,
sigN: 10,
filename: "~/temp/temp.csv",
colLabelL: [ "mean0", "mean1", "db0", "db1", "db2", "db3", "db4", "db5", "db6" ]
}
pvoc_template: {
wndSmpN: 2048, // required FT window size in samples
hopSmpN: 512, // required Sample offset between successive FT windows
procSmpN: 512, // required Output samples for each FT frame processed
presetLabel: preset_1, // required
inGain: 1.0, // optional
outGain: 1.0, // optional
function: pvoc_template,
args:
{
foo: 1,
blah: 2,
}
}
spec_dist: {
wndSmpN: 2048,
hopSmpN: 512,
procSmpN: 512,
inGain: 1.0, // optional
outGain: 1.0, // optional
function: spec_dist,
args: {
ceiling: 30.0,
expo: 2.0,
thresh: 54.0,
uprSlope: -0.7,
lwrSlope: 2.0,
mix: 0.0
}
}
}
flow_class: {
audioFileIn: {
vars: {
out:{ type:audio, doc:"Audio file output" },
}
}
audioFileOut: {
vars: {
in:{ type:audio, srcFl:true, doc:"Audio file input." }
}
}
pv_analysis: {
vars: {
in: { type:audio, srcFl:true, doc:"Audio input." },
out: { type:spectrum, doc:"Spectrum output." }
}
}
pv_synthesis: {
vars: {
in: { type:spectrum, srcFl:true, doc:"Spectrum input." },
out: { type:audio, doc:"Audio output." }
}
}
spec_dist: {
vars: {
in: { type:spectrum, srcFl:true, doc:"Spectrum input." },
out: { type:spectrum, doc:"Spectrum output." },
ceiling: { type:real, doc:"Ceiling parameter."},
expo: { type:real, doc:"Exponent parameter."},
thresh: { type:real, doc:"Threshold parameter."},
uprSlope: { type:real, doc:"Upper slope parameter."},
lwrSlope: { type:real, doc:"Lower slope parameter."},
mix: { type:real, doc:"Mix parameter."},
}
presets: {
a: {
ceiling: [ 30.0, 30.0 ],
expo: [ 2.0, 2.0 ],
thresh: [ 54.0, 55.0 ],
uprSlope: [ -0.7, -0.7 ],
lwrSlope: [ 2.0, 2.0 ],
mix: [ 0.0 0.0 ]
},
}
}
}
flow_test: {
framesPerCycle:64,
maxCycleCount:15000,
network: {
srcFn: { class: audioFileIn, argLabel:"default", args:{ default:{fn:"/home/kevin/temp/audio.wav", eofFl:true } } },
dstFn: { class: audioFileOut, in:{ in:srcFn.out }, args:{ default:{fn:"/home/kevin/temp/audio_flow_out.wav"} } },
}
}
flow_pv: {
framesPerCycle:64,
maxCycleCount:15000,
network: {
srcFn: { class: audioFileIn, argLabel:"default", args:{ default:{fn:"/home/kevin/temp/audio.wav", eofFl:true } } },
pva: { class: pv_analysis, in:{ in:srcFn.out }, args:{ default:{ wndSmpCnt:512, hopSmpCnt:64, hzFl:false } } },
pvs: { class: pv_synthesis, in:{ in:pva.out }, args:{ default:{ } } },
dstFn: { class: audioFileOut, in:{ in:pvs.out }, args:{ default:{fn:"/home/kevin/temp/audio_flow_out.wav"} } },
}
}
flow_spec_dist: {
framesPerCycle:64,
maxCycleCount:15000,
network: {
srcFn: { class: audioFileIn, argLabel:"default", args:{ default:{fn:"/home/kevin/temp/audio.wav", eofFl:true } } },
pva: { class: pv_analysis, in:{ in:srcFn.out }, args:{ default:{ wndSmpCnt:512, hopSmpCnt:64, hzFl:false } } },
sd: { class: spec_dist, in:{ in:pva.out }, preset:a, args:{ default:{ thresh:80 }}},
pvs: { class: pv_synthesis, in:{ in:sd.out }, args:{ default:{ } } },
dstFn: { class: audioFileOut, in:{ in:pvs.out }, args:{ default:{fn:"/home/kevin/temp/audio_flow_out.wav"} } },
}
}
}

View File

@ -20,7 +20,12 @@
#include "cwSerialPortSrv.h"
#include "cwSocket.h"
#include "cwUtility.h"
#include "cwMath.h"
#include "cwDsp.h"
#include "cwAudioTransforms.h"
#include "cwAudioFileProc.h"
#include "cwPvAudioFileProc.h"
#include "cwFlow.h"
#if defined(cwWEBSOCK)
#include "cwWebSock.h"
@ -53,6 +58,8 @@
#include "cwIo.h"
#include "cwIoTest.h"
#include "cwIoAudioMidi.h"
#include "cwIoAudioMidiApp.h"
#include "cwIoMidiRecordPlay.h"
#endif
#if !defined(cwWEB)
@ -359,16 +366,32 @@ cw::rc_t audioFileGenerate( const cw::object_t* cfg, const cw::object_t* args
cw::rc_t fftTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { return cw::dsp::fft::test(); }
cw::rc_t ifftTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { return cw::dsp::ifft::test(); }
cw::rc_t convolveTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { return cw::dsp::convolve::test(); }
cw::rc_t audioTransformsTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { return cw::dsp::test(args); }
cw::rc_t amToMidiFile( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { return cw::midi_record_play::am_to_midi_file(args); }
cw::rc_t audioFileProc( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { return cw::afop::file_processor(args); }
cw::rc_t pvocFileProc( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { return cw::afop::pvoc_file_processor(args); }
cw::rc_t socketMdnsTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { return cw::net::mdns::test(); }
cw::rc_t dnsSdTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { return cw::net::dnssd::test(); }
cw::rc_t euConTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { return cw::eucon::test(); }
cw::rc_t flowTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] )
{
cw::rc_t rc;
const cw::object_t* flow_class = nullptr;
if((rc = cfg->getv("flow_class",flow_class)) != cw::kOkRC )
return cwLogError(rc,"The 'flow_class' specification object was not found.");
return cw::flow::test(flow_class,args);
}
#if defined(cwWEBSOCK)
cw::rc_t websockSrvTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { return cw::websockSrvTest(cfg); }
cw::rc_t uiTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { return cw::ui::test(args); }
#if defined(cwALSA)
cw::rc_t ioTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { return cw::io::test(args); }
cw::rc_t ioAudioMidiTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { return cw::io::audio_midi::main(args); }
cw::rc_t ioAudioMidiTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { return cw::audio_midi_app::main(args); }
#else
cw::rc_t _no_alsa_websock() { return cwLogError(cw::kResourceNotAvailableRC,"Websock or ALSA functionality not included in this build."); }
cw::rc_t ioTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { return _no_alsa_websock(); }
@ -653,6 +676,9 @@ const cw::object_t* _locateArgsRecd( const cw::object_t* cfg, const char*& cfgLa
int main( int argc, const char* argv[] )
{
cw::rc_t rc = cw::kOkRC;
cw::object_t* cfg = nullptr;
const char* cfgFn = nullptr;
const char* mode = nullptr;
typedef struct func_str
{
@ -713,17 +739,29 @@ int main( int argc, const char* argv[] )
{ "fft", fftTest },
{ "ifft", ifftTest },
{ "convolve", convolveTest },
{ "audio_transforms", audioTransformsTest },
{ "am_to_midi_file", amToMidiFile },
{ "audio_file_proc", audioFileProc },
{ "pvoc_file_proc", pvocFileProc },
{ "flow_test", flowTest },
{ "flow_pv", flowTest },
{ "flow_spec_dist", flowTest },
{ "stub", stubTest },
{ nullptr, nullptr }
};
// read the command line
cw::object_t* cfg = nullptr;
const char* cfgFn = argc > 1 ? argv[1] : nullptr;
const char* mode = argc > 2 ? argv[2] : nullptr;
cfgFn = argc > 1 ? argv[1] : nullptr;
mode = argc > 2 ? argv[2] : nullptr;
cw::log::createGlobal();
if( argc != 3 )
{
cwLogInfo("cwtest <config_filename> <mode>");
goto errLabel;
}
// if valid command line args were given and the cfg file was successfully read
if( cfgFn != nullptr && mode != nullptr && objectFromFile( cfgFn, cfg ) == cw::kOkRC )
@ -732,12 +770,11 @@ int main( int argc, const char* argv[] )
const cw::object_t* args;
int i = 0;
// if the arg's record was not found
if((args = _locateArgsRecd(cfg,mode)) == nullptr )
goto errLabel;
// if the arg's record was found
if((args = _locateArgsRecd(cfg,mode)) != nullptr )
{
// locate the requested function and call it
for(i=0; modeArray[i].label!=nullptr; ++i)
for(int i=0; modeArray[i].label!=nullptr; ++i)
{
if( cw::textCompare(modeArray[i].label,mode)==0 )
{
@ -749,12 +786,13 @@ int main( int argc, const char* argv[] )
// if the requested function was not found
if( modeArray[i].label == nullptr )
rc = cwLogError(cw::kInvalidArgRC,"The mode selector: '%s' is not valid.", cwStringNullGuard(mode));
}
errLabel:
if( cfg != nullptr )
cfg->free();
}
errLabel:
cw::log::destroyGlobal();
return (int)rc;