void plot_file_process_run(ShortTimeProcess &process) { std::string input_file = getAudioPath(); input_file += "/example16000.wav"; SF_INFO sf_info_in; SNDFILE *snd_file_in = sf_open(input_file.c_str(), SFM_READ, &sf_info_in); EXPECT_FALSE(snd_file_in == NULL); if (snd_file_in == NULL) return; int nframes = 1024; int out_n_frames = nframes + process.getMaxLatency(); int nchannels = sf_info_in.channels; int sampling_rate = sf_info_in.samplerate; EXPECT_EQ(1,nchannels); double data[nframes * nchannels]; double out_data[out_n_frames * nchannels + process.getMaxLatency()]; std::vector<double*> in_channels, out_channels; in_channels.push_back(data); out_channels.push_back(out_data); int read_frames; while ( (read_frames = sf_readf_double(snd_file_in, data, nframes) ) > 0) { process.process(in_channels, read_frames, out_channels, out_n_frames); usleep(1000000.0F * read_frames / sampling_rate ); } }
/*luadoc @function playFile(name) Play a file from the SD card @param path (string) full path to wav file (i.e. “/SOUNDS/en/system/tada.wav”) Introduced in 2.1.0: If you use a relative path, the current language is appended to the path (example: for English language: `/SOUNDS/en` is appended) @status current Introduced in 2.0.0, changed in 2.1.0 */ static int luaPlayFile(lua_State *L) { const char * filename = luaL_checkstring(L, 1); if (filename[0] != '/') { // relative sound file path - use current language dir for absolute path char file[AUDIO_FILENAME_MAXLEN+1]; char * str = getAudioPath(file); strncpy(str, filename, AUDIO_FILENAME_MAXLEN - (str-file)); file[AUDIO_FILENAME_MAXLEN] = 0; PLAY_FILE(file, 0, 0); } else { PLAY_FILE(filename, 0, 0); } return 0; }
char * getSystemAudioPath(char * path) { char * str = getAudioPath(path); strcpy(str, SYSTEM_SUBDIR "/"); return str + sizeof(SYSTEM_SUBDIR); }