diff --git a/Record/ProcessFile.cpp b/Record/ProcessFile.cpp index 883b12d..6b2aea6 100644 --- a/Record/ProcessFile.cpp +++ b/Record/ProcessFile.cpp @@ -1,5 +1,4 @@ #include "IoContext.h" -// #include "RKAP_3A.h" #include "SpeexDsp.h" #include "WebRtcAecm.h" #include "api/audio/echo_canceller3_config.h" @@ -52,15 +51,24 @@ void ProcessFileTask::setDsp(Dsp dsp) { } } +// ./build/Record/Record --file --dsp=aecm // ./Record --file --dsp=aecm void ProcessFileTask::run() { - m_speakerIfs = std::make_shared("/sdcard/speaker_16k.pcm", std::ifstream::binary); - m_micIfs = std::make_shared("/sdcard/micin_16k.pcm", std::ifstream::binary); +#ifdef __RV1109__ + constexpr auto MicFile = "/sdcard/micin_16k.pcm"; + constexpr auto SpeakerFile = "/sdcard/speaker_16k.pcm"; + +#else + constexpr auto MicFile = "resources/micin_16k.pcm"; + constexpr auto SpeakerFile = "resources/speaker_16k.pcm"; +#endif + m_speakerIfs = std::make_shared(SpeakerFile, std::ifstream::binary); + m_micIfs = std::make_shared(MicFile, std::ifstream::binary); std::ostringstream oss; - oss << DumpPath << "/out_" << dspToString(m_dsp) << "_16k.pcm"; + oss << DumpPath << "/out_" << dspToString(m_dsp) << "_16k.wav"; m_outFilename = oss.str(); - m_ofs = std::make_shared(m_outFilename, std::ofstream::binary); + m_ofs = std::make_shared>(m_outFilename, 1, 16000); oss.str(""); oss << DumpPath << "/ns_" << dspToString(m_dsp) << "_16k.pcm"; @@ -130,6 +138,6 @@ void ProcessFileTask::process() { } else { auto elapsed = std::chrono::duration_cast(std::chrono::system_clock::now() - m_begin); LOG(info) << "process file finished, out: " << m_outFilename << ", elapsed: " << elapsed; - std::exit(0); + ioConext->stop(); } } \ No newline at end of file diff --git a/Record/main.h b/Record/main.h index 685c619..9de7f52 100644 --- a/Record/main.h +++ b/Record/main.h @@ -4,6 +4,7 @@ #include "RkAudio.h" #include #include +#include "WavWriter.h" class SpeexDsp; class WebRtcAecm; @@ -15,7 +16,11 @@ enum Dsp { Aec3, }; +#ifdef __RV1109__ constexpr auto DumpPath = "/sdcard/data"; +#else +constexpr auto DumpPath = "./build/data"; +#endif class Task { public: @@ -95,7 +100,7 @@ private: std::shared_ptr m_webRtcAecm; std::shared_ptr m_speakerIfs; std::shared_ptr m_micIfs; - std::shared_ptr m_ofs; + std::shared_ptr> m_ofs; std::shared_ptr m_nsOfs; // 降噪后的文件 std::string m_outFilename; std::chrono::system_clock::time_point m_begin; diff --git a/resources/micin_16k.pcm b/resources/micin_16k.pcm new file mode 100644 index 0000000..e7befe9 Binary files /dev/null and b/resources/micin_16k.pcm differ diff --git a/resources/speaker_16k.pcm b/resources/speaker_16k.pcm new file mode 100644 index 0000000..81835c2 Binary files /dev/null and b/resources/speaker_16k.pcm differ