43template<
typename Processor>
45 ,
const std::string& infilename
46 ,
const std::string& outfilename)
48 std::cout <<
"Opening file \"" << infilename <<
"\" ..." << std::endl;
50 auto in = SndfileHandle(infilename, SFM_READ);
52 if (
int err = in.error())
54 std::cout << in.strError() << std::endl;
58 if (in.samplerate() !=
static_cast<int>(processor.sample_rate()))
60 std::cout <<
"Samplerate mismatch!" << std::endl;
64 if (in.channels() != processor.in_channels())
66 std::cout <<
"Input channel mismatch!" << std::endl;
70 auto out = SndfileHandle(outfilename, SFM_WRITE
71 , in.format(), processor.out_channels(), in.samplerate());
73 if (
int err = out.error())
75 std::cout << out.strError() << std::endl;
79 auto format_info = SF_FORMAT_INFO();
80 format_info.format = in.format();
81 in.command(SFC_GET_FORMAT_INFO, &format_info,
sizeof(format_info));
83 std::cout <<
"format: " << format_info.name << std::endl;
85 std::cout <<
"frames: " << in.frames()
86 <<
" (" << in.frames()/in.samplerate() <<
" seconds)" << std::endl;
87 std::cout <<
"channels: " << in.channels() << std::endl;
88 std::cout <<
"samplerate: " << in.samplerate() << std::endl;
90 auto blocksize = processor.block_size();
97 size_t(processor.out_channels()), blocksize);
103 sf_count_t actual_frames = 0;
104 while ((actual_frames = in.readf(m_in.data()
105 ,
static_cast<sf_count_t
>(blocksize))) != 0)
109 processor.audio_callback(blocksize
115 out.writef(m_out.data(), actual_frames);
120 processor.deactivate();
Two-dimensional data storage for row- and column-wise access.
has_begin_and_end< slices_iterator > slices
Access to Slices; use slices.begin() and slices.end()
pointer const * get_channel_ptrs() const
Get array of pointers to the channels.
void set_channels(const Ch &ch)
Copy channels from another matrix.
Audio Processing Framework.
int mimoprocessor_file_io(Processor &processor, const std::string &infilename, const std::string &outfilename)
Use MimoProcessor-based object with multichannel audio file input and output.