Mercurial > octave-nkf
comparison libinterp/dldfcn/audioread.cc @ 19847:879cff0c05dc
audiowrite: Accept a row vector input as a single channel
* audioread.cc (Faudiowrite): Accept a row vector input as a single channel.
author | Mike Miller <mtmiller@ieee.org> |
---|---|
date | Sat, 21 Feb 2015 11:53:41 -0500 |
parents | f9ca80482c41 |
children | ed5ee3f610db |
comparison
equal
deleted
inserted
replaced
19846:f9ca80482c41 | 19847:879cff0c05dc |
---|---|
304 std::string filename = args(0).string_value (); | 304 std::string filename = args(0).string_value (); |
305 | 305 |
306 if (error_state) | 306 if (error_state) |
307 return retval; | 307 return retval; |
308 | 308 |
309 const Matrix audio = args(1).matrix_value (); | 309 Matrix audio = args(1).matrix_value (); |
310 | 310 |
311 if (error_state) | 311 if (error_state) |
312 return retval; | 312 return retval; |
313 | 313 |
314 double bias = 0.0; | 314 double bias = 0.0; |
333 | 333 |
334 std::string ext = filename.substr (filename.find_last_of (".") + 1); | 334 std::string ext = filename.substr (filename.find_last_of (".") + 1); |
335 std::transform (ext.begin (), ext.end (), ext.begin (), ::tolower); | 335 std::transform (ext.begin (), ext.end (), ext.begin (), ::tolower); |
336 | 336 |
337 sf_count_t items_to_write = audio.rows () * audio.columns (); | 337 sf_count_t items_to_write = audio.rows () * audio.columns (); |
338 | |
339 if (audio.rows () == 1) | |
340 audio = audio.transpose (); | |
338 | 341 |
339 OCTAVE_LOCAL_BUFFER (float, data, items_to_write); | 342 OCTAVE_LOCAL_BUFFER (float, data, items_to_write); |
340 | 343 |
341 sf_count_t idx = 0; | 344 sf_count_t idx = 0; |
342 for (int i = 0; i < audio.rows (); i++) | 345 for (int i = 0; i < audio.rows (); i++) |