26 #if defined (HAVE_CONFIG_H)
54 #if defined (HAVE_PORTAUDIO)
56 #include <portaudio.h>
59 bits_to_format (
int bits)
117 #if defined (HAVE_PORTAUDIO)
119 int nargin = args.length ();
128 PaError err = Pa_Initialize ();
130 if (err != paNoError)
131 error (
"audiodevinfo: PortAudio initialization failed");
133 int num_devices = Pa_GetDeviceCount ();
139 numinput = numoutput = 0;
140 for (
int i = 0; i < num_devices; i++)
142 const PaDeviceInfo *device_info = Pa_GetDeviceInfo (i);
147 "invalid audio device ID = %d", i);
151 if (device_info->maxInputChannels != 0)
154 if (device_info->maxOutputChannels != 0)
167 for (
int i = 0; i < num_devices; i++)
169 const PaDeviceInfo *device_info = Pa_GetDeviceInfo (i);
174 "invalid audio device ID = %d", i);
178 const PaHostApiInfo *api_info = Pa_GetHostApiInfo (device_info->hostApi);
180 const char *driver = (api_info ? api_info->name :
"");
183 sprintf (
name,
"%s (%s)", device_info->name, driver);
185 if (device_info->maxInputChannels != 0)
187 input_name(idx_i) =
name;
188 input_driver_version(idx_i) = driver;
193 if (device_info->maxOutputChannels != 0)
195 output_name(idx_o) =
name;
196 output_driver_version(idx_o) = driver;
197 output_id(idx_o) = i;
203 inputdev.
setfield (
"Name", input_name);
204 inputdev.
setfield (
"DriverVersion", input_driver_version);
206 outputdev.
setfield (
"Name", output_name);
207 outputdev.
setfield (
"DriverVersion", output_driver_version);
208 outputdev.
setfield (
"ID", output_id);
209 devinfo.
setfield (
"input", inputdev);
210 devinfo.
setfield (
"output", outputdev);
220 else if (nargin == 1)
222 if (args(0).int_value () == 0)
224 else if (args(0).int_value () == 1)
227 error (
"audiodevinfo: specify 0 for output and 1 for input devices");
230 else if (nargin == 2)
233 int outin = args(0).int_value ();
234 if (args(1).is_string ())
236 std::string
name = args(1).string_value ();
239 for (
int i = 0; i < numoutput; i++)
241 if (output_name(i).string_value () ==
name)
251 for (
int i = 0; i < numinput; i++)
253 if (input_name(i).string_value () ==
name)
262 error (
"audiodevinfo: specify 0 for output and 1 for input devices");
268 for (
int i = 0; i < numoutput; i++)
270 if (output_id(i).int_value () == args(1).int_value ())
280 for (
int i = 0; i < numinput; i++)
282 if (input_id(i).int_value () == args(1).int_value ())
291 error (
"audiodevinfo: specify 0 for output and 1 for input devices");
295 error (
"audiodevinfo: no device found for the specified criteria");
298 else if (nargin == 3)
301 int outin = args(0).int_value ();
302 int id = args(1).int_value ();
304 std::string arg3 = args(2).string_value ();
305 std::transform (arg3.begin (), arg3.end (), arg3.begin (), tolower);
306 if (arg3 !=
"driverversion")
307 error (
"audiodevinfo: third argument must be \"DriverVersion\"");
311 for (
int i = 0; i < numoutput; i++)
313 if (output_id(i).int_value () ==
id)
316 retval = output_driver_version(i);
323 for (
int i = 0; i < numinput; i++)
325 if (input_id(i).int_value () ==
id)
328 retval = input_driver_version(i);
334 error (
"audiodevinfo: specify 0 for output and 1 for input devices");
337 error (
"audiodevinfo: no device found for the specified criteria");
340 else if (nargin == 4)
342 int io = args(0).int_value ();
343 int rate = args(1).int_value ();
344 int bits = args(2).int_value ();
345 int chans = args(3).int_value ();
347 for (
int i = 0; i < num_devices; i++)
349 PaStreamParameters stream_parameters;
350 stream_parameters.device = i;
351 stream_parameters.channelCount = chans;
352 PaSampleFormat
format = bits_to_format (bits);
355 stream_parameters.sampleFormat =
format;
357 error (
"audiodevinfo: invalid bits per sample format");
359 const PaDeviceInfo *device_info = Pa_GetDeviceInfo (i);
364 "invalid audio device ID = %d", i);
368 stream_parameters.suggestedLatency
369 = device_info->defaultLowInputLatency;
371 stream_parameters.hostApiSpecificStreamInfo =
nullptr;
375 if (device_info->maxOutputChannels < chans)
378 err = Pa_IsFormatSupported (
nullptr, &stream_parameters, rate);
380 if (err == paFormatIsSupported)
388 if (device_info->maxInputChannels < chans)
391 err = Pa_IsFormatSupported (&stream_parameters,
nullptr, rate);
392 if (err == paFormatIsSupported)
402 else if (nargin == 5)
404 int io = args(0).int_value ();
405 int id = args(1).int_value ();
406 int rate = args(2).int_value ();
407 int bits = args(3).int_value ();
408 int chans = args(4).int_value ();
409 PaStreamParameters stream_parameters;
410 stream_parameters.device = id;
411 stream_parameters.channelCount = chans;
412 PaSampleFormat
format = bits_to_format (bits);
414 stream_parameters.sampleFormat =
format;
416 error (
"audiodevinfo: invalid bits per sample format");
418 const PaDeviceInfo *device_info = Pa_GetDeviceInfo (
id);
421 error (
"audiodevinfo: invalid audio device ID = %d",
id);
423 stream_parameters.suggestedLatency
424 = device_info->defaultLowInputLatency;
426 stream_parameters.hostApiSpecificStreamInfo =
nullptr;
429 if (device_info->maxOutputChannels < chans)
434 err = Pa_IsFormatSupported (
nullptr, &stream_parameters, rate);
435 if (err == paFormatIsSupported)
443 if (device_info->maxInputChannels < chans)
448 err = Pa_IsFormatSupported (&stream_parameters,
nullptr, rate);
449 if (err == paFormatIsSupported)
456 error (
"audiodevinfo: specify 0 for output and 1 for input devices");
464 octave_unused_parameter (args);
467 "audio playback and recording through PortAudio");
507 #if defined (HAVE_PORTAUDIO)
509 enum audio_type { TYPE_INT8, TYPE_UINT8, TYPE_UINT16, TYPE_DOUBLE };
518 double player_value (
void)
const {
return 0; }
519 virtual double scalar_value (
bool =
false)
const {
return 0; }
520 void print (std::ostream& os,
bool pr_as_read_syntax =
false);
521 void print_raw (std::ostream& os,
bool pr_as_read_syntax)
const;
532 void set_y (std::string fn);
536 void set_fs (
int fs);
538 void set_nbits (
int nbits);
539 int get_nbits (
void);
540 void set_id (
int id);
542 int get_channels (
void);
543 audio_type get_type (
void);
545 void set_sample_number (
unsigned int sample);
546 unsigned int get_sample_number (
void);
547 unsigned int get_total_samples (
void);
548 void set_end_sample (
unsigned int sample);
549 unsigned int get_end_sample (
void);
550 void reset_end_sample (
void);
555 PaStream * get_stream (
void);
557 void playblocking (
void);
562 bool isplaying (
void);
571 unsigned int sample_number;
572 unsigned int end_sample;
579 PaStreamParameters output_parameters;
588 octave_play_callback (
const void *,
void *output,
unsigned long frames,
589 const PaStreamCallbackTimeInfo *,
590 PaStreamCallbackFlags,
void *data)
592 audioplayer *player =
static_cast<audioplayer *
> (data);
595 error (
"audio player callback function called without player");
599 ovl (
static_cast<double> (frames)), 1);
602 error (
"audio player callback function failed");
605 int return_status =
retval(1).int_value ();
607 if (frames - sound.
rows () != 0 || sound.
columns () < 1
609 error (
"audio player callback function failed");
617 ? sound_l : sound.
column (1));
619 const double *p_l = sound_l.
data ();
620 const double *p_r = sound_r.
data ();
622 switch (player->get_nbits ())
626 static double scale_factor =
std::pow (2.0, 7) - 1.0;
628 int8_t *buffer =
static_cast<int8_t *
> (output);
630 for (
unsigned long i = 0; i < frames; i++)
632 buffer[2*i] = p_l[i] * scale_factor;
633 buffer[2*i+1] = p_r[i] * scale_factor;
640 static double scale_factor =
std::pow (2.0, 15) - 1.0;
642 int16_t *buffer =
static_cast<int16_t *
> (output);
644 for (
unsigned long i = 0; i < frames; i++)
646 buffer[2*i] = p_l[i] * scale_factor;
647 buffer[2*i+1] = p_r[i] * scale_factor;
654 static double scale_factor =
std::pow (2.0, 23) - 1.0;
658 uint8_t *buffer =
static_cast<uint8_t *
> (output);
660 for (
unsigned long i = 0; i < frames; i++)
662 int32_t sample_l = p_l[i];
663 int32_t sample_r = p_r[i];
665 sample_l &= 0x00ffffff;
666 sample_r &= 0x00ffffff;
668 uint8_t *_sample_l =
reinterpret_cast<uint8_t *
> (&sample_l);
669 uint8_t *_sample_r =
reinterpret_cast<uint8_t *
> (&sample_r);
671 unsigned long offset = i * 6;
673 buffer[offset+0] = _sample_l[0+big_endian] * scale_factor;
674 buffer[offset+1] = _sample_l[1+big_endian] * scale_factor;
675 buffer[offset+2] = _sample_l[2+big_endian] * scale_factor;
677 buffer[offset+3] = _sample_r[0+big_endian] * scale_factor;
678 buffer[offset+4] = _sample_r[1+big_endian] * scale_factor;
679 buffer[offset+5] = _sample_r[2+big_endian] * scale_factor;
685 error (
"invalid player bit depth in callback function");
688 return return_status;
692 portaudio_play_callback (
const void *,
void *output,
unsigned long frames,
693 const PaStreamCallbackTimeInfo*,
694 PaStreamCallbackFlags,
void *data)
696 audioplayer *player =
static_cast<audioplayer *
> (data);
699 error (
"audio player callback function called without player");
706 const RowVector sound_l = player->get_left ();
707 const RowVector sound_r = player->get_right ();
709 const double *pl = sound_l.
data ();
710 const double *pr = sound_r.
data ();
712 if (player->get_type () == TYPE_DOUBLE)
714 switch (player->get_nbits ())
718 static double scale_factor =
std::pow (2.0, 7) - 1.0;
720 int8_t *buffer =
static_cast<int8_t *
> (output);
722 for (
unsigned long j = 0; j < frames; j++)
724 unsigned int sample_number = player->get_sample_number ();
726 if (sample_number >= player->get_end_sample ())
729 unsigned long offset = j * 2;
731 buffer[offset+0] = pl[sample_number] * scale_factor;
732 buffer[offset+1] = pr[sample_number] * scale_factor;
734 player->set_sample_number (sample_number + 1);
741 static double scale_factor =
std::pow (2.0, 15) - 1.0;
743 int16_t *buffer =
static_cast<int16_t *
> (output);
745 for (
unsigned long j = 0; j < frames; j++)
747 unsigned int sample_number = player->get_sample_number ();
749 if (sample_number >= player->get_end_sample ())
752 unsigned long offset = j * 2;
754 buffer[offset+0] = pl[sample_number] * scale_factor;
755 buffer[offset+1] = pr[sample_number] * scale_factor;
757 player->set_sample_number (sample_number + 1);
764 static double scale_factor =
std::pow (2.0, 23) - 1.0;
768 uint8_t *buffer =
static_cast<uint8_t *
> (output);
770 for (
unsigned long j = 0; j < frames; j++)
772 unsigned int sample_number = player->get_sample_number ();
774 if (sample_number >= player->get_end_sample ())
777 int32_t sample_l = pl[sample_number] * scale_factor;
778 int32_t sample_r = pr[sample_number] * scale_factor;
780 sample_l &= 0x00ffffff;
781 sample_r &= 0x00ffffff;
783 uint8_t *_sample_l =
reinterpret_cast<uint8_t *
> (&sample_l);
784 uint8_t *_sample_r =
reinterpret_cast<uint8_t *
> (&sample_r);
786 unsigned long offset = j * 6;
788 buffer[offset+0] = _sample_l[0+big_endian];
789 buffer[offset+1] = _sample_l[1+big_endian];
790 buffer[offset+2] = _sample_l[2+big_endian];
792 buffer[offset+3] = _sample_r[0+big_endian];
793 buffer[offset+4] = _sample_r[1+big_endian];
794 buffer[offset+5] = _sample_r[2+big_endian];
796 player->set_sample_number (sample_number + 1);
802 error (
"invalid player bit depth in callback function");
805 else if (player->get_type () == TYPE_INT8)
807 int8_t *buffer =
static_cast<int8_t *
> (output);
809 for (
unsigned long j = 0; j < frames; j++)
811 unsigned int sample_number = player->get_sample_number ();
813 if (sample_number >= player->get_end_sample ())
816 unsigned long offset = j * 2;
818 buffer[offset+0] = pl[sample_number];
819 buffer[offset+1] = pr[sample_number];
821 player->set_sample_number (sample_number + 1);
824 else if (player->get_type () == TYPE_UINT8)
826 uint8_t *buffer =
static_cast<uint8_t *
> (output);
828 for (
unsigned long j = 0; j < frames; j++)
830 unsigned int sample_number = player->get_sample_number ();
832 if (sample_number >= player->get_end_sample ())
835 unsigned long offset = j * 2;
837 buffer[offset+0] = pl[sample_number];
838 buffer[offset+1] = pr[sample_number];
840 player->set_sample_number (sample_number + 1);
843 else if (player->get_type () == TYPE_UINT16)
845 int16_t *buffer =
static_cast<int16_t *
> (output);
847 for (
unsigned long j = 0; j < frames; j++)
849 unsigned int sample_number = player->get_sample_number ();
851 if (sample_number >= player->get_end_sample ())
854 unsigned long offset = j * 2;
856 buffer[offset+0] = pl[sample_number];
857 buffer[offset+1] = pr[sample_number];
859 player->set_sample_number (sample_number + 1);
867 safe_audioplayer_stop (audioplayer *player)
872 audioplayer::audioplayer (
void)
873 : octave_callback_function (nullptr),
874 id (-1), fs (0), nbits (16), channels (0), sample_number (0),
875 end_sample (-1), tag (
""), y (), userdata (
Matrix ()),
876 left (), right (), stream (nullptr), output_parameters (),
type ()
879 audioplayer::~audioplayer (
void)
884 "interrupting playing audioplayer");
890 audioplayer::print (std::ostream& os,
bool pr_as_read_syntax)
892 print_raw (os, pr_as_read_syntax);
897 audioplayer::print_raw (std::ostream& os,
bool)
const
903 audioplayer::init_fn (
void)
905 if (Pa_Initialize () != paNoError)
906 error (
"audioplayer: initialization error");
908 if (Pa_GetDeviceCount () < 1)
909 error (
"audioplayer: no audio devices found or available");
911 int device = get_id ();
914 device = Pa_GetDefaultOutputDevice ();
916 output_parameters.device = device;
917 output_parameters.channelCount = 2;
918 output_parameters.sampleFormat = bits_to_format (get_nbits ());
920 const PaDeviceInfo *device_info = Pa_GetDeviceInfo (device);
924 "invalid default audio device ID = %d", device);
926 output_parameters.suggestedLatency
927 = (device_info ? device_info->defaultHighOutputLatency : -1);
929 output_parameters.hostApiSpecificStreamInfo =
nullptr;
933 audioplayer::init (
void)
941 if (Pa_Initialize () != paNoError)
942 error (
"audioplayer: initialization error");
944 if (Pa_GetDeviceCount () < 1)
945 error (
"audioplayer: no audio devices found or available");
947 int device = get_id ();
950 device = Pa_GetDefaultOutputDevice ();
952 output_parameters.device = device;
953 output_parameters.channelCount = 2;
955 if (
type == TYPE_DOUBLE)
956 output_parameters.sampleFormat = bits_to_format (get_nbits ());
957 else if (
type == TYPE_INT8)
958 output_parameters.sampleFormat = paInt8;
959 else if (
type == TYPE_UINT8)
960 output_parameters.sampleFormat = paUInt8;
961 else if (
type == TYPE_UINT16)
962 output_parameters.sampleFormat = paInt16;
964 const PaDeviceInfo *device_info = Pa_GetDeviceInfo (device);
968 "invalid default audio device ID = %d", device);
970 output_parameters.suggestedLatency
971 = (device_info ? device_info->defaultHighOutputLatency : -1);
973 output_parameters.hostApiSpecificStreamInfo =
nullptr;
993 channels = y.
rows ();
1005 octave_callback_function = fn;
1007 reset_end_sample ();
1011 audioplayer::get_y (
void)
1017 audioplayer::get_left (
void)
const
1023 audioplayer::get_right (
void)
const
1025 return channels == 1 ?
left : right;
1029 audioplayer::set_fs (
int fs_arg)
1035 audioplayer::get_fs (
void)
1041 audioplayer::set_nbits (
int nbits_arg)
1047 audioplayer::get_nbits (
void)
1053 audioplayer::set_id (
int id_arg)
1059 audioplayer::get_id (
void)
1065 audioplayer::get_channels (
void)
1071 audioplayer::get_type (
void)
1077 audioplayer::set_sample_number (
unsigned int sample_number_arg)
1079 sample_number = sample_number_arg;
1083 audioplayer::get_sample_number (
void)
1085 return sample_number;
1089 audioplayer::get_total_samples (
void)
1091 return left.numel ();
1095 audioplayer::set_end_sample (
unsigned int end_sample_arg)
1097 end_sample = end_sample_arg;
1101 audioplayer::get_end_sample (
void)
1107 audioplayer::reset_end_sample (
void)
1109 set_end_sample (
left.numel ());
1113 audioplayer::set_tag (
const charMatrix& tag_arg)
1119 audioplayer::get_tag (
void)
1125 audioplayer::set_userdata (
const octave_value& userdata_arg)
1127 userdata = userdata_arg;
1131 audioplayer::get_userdata (
void)
1137 audioplayer::playblocking (
void)
1142 const unsigned int buffer_size = get_fs () / 20;
1146 err = Pa_OpenStream (&stream,
nullptr, &(output_parameters), get_fs (),
1147 buffer_size, paClipOff,
nullptr,
nullptr);
1148 if (err != paNoError)
1149 error (
"audioplayer: unable to open audio playback stream");
1151 err = Pa_StartStream (stream);
1152 if (err != paNoError)
1153 error (
"audioplayer: unable to start audio playback stream");
1155 unsigned int start, end;
1156 start = get_sample_number ();
1157 end = get_end_sample ();
1161 frame.
add_fcn (safe_audioplayer_stop,
this);
1163 for (
unsigned int i = start; i < end; i += buffer_size)
1167 if (octave_callback_function !=
nullptr)
1168 octave_play_callback (
nullptr, buffer, buffer_size,
nullptr, 0,
this);
1170 portaudio_play_callback (
nullptr, buffer, buffer_size,
nullptr, 0,
this);
1172 err = Pa_WriteStream (stream, buffer, buffer_size);
1177 audioplayer::play (
void)
1182 const unsigned int buffer_size = get_fs () / 20;
1185 if (octave_callback_function !=
nullptr)
1186 err = Pa_OpenStream (&stream,
nullptr, &(output_parameters),
1187 get_fs (), buffer_size, paClipOff,
1188 octave_play_callback,
this);
1190 err = Pa_OpenStream (&stream,
nullptr, &(output_parameters),
1191 get_fs (), buffer_size, paClipOff,
1192 portaudio_play_callback,
this);
1194 if (err != paNoError)
1195 error (
"audioplayer: failed to open audio playback stream");
1197 err = Pa_StartStream (stream);
1198 if (err != paNoError)
1199 error (
"audioplayer: failed to start audio playback stream");
1203 audioplayer::pause (
void)
1205 if (get_stream () ==
nullptr)
1209 err = Pa_StopStream (stream);
1210 if (err != paNoError)
1211 error (
"audioplayer: failed to stop audio playback stream");
1215 audioplayer::resume (
void)
1217 if (get_stream () ==
nullptr)
1221 err = Pa_StartStream (stream);
1222 if (err != paNoError)
1223 error (
"audioplayer: failed to start audio playback stream");
1227 audioplayer::get_stream (
void)
1233 audioplayer::stop (
void)
1235 if (get_stream () ==
nullptr)
1239 set_sample_number (0);
1240 reset_end_sample ();
1241 if (! Pa_IsStreamStopped (get_stream ()))
1243 err = Pa_AbortStream (get_stream ());
1244 if (err != paNoError)
1245 error (
"audioplayer: failed to stop audio playback stream");
1248 err = Pa_CloseStream (get_stream ());
1249 if (err != paNoError)
1250 error (
"audioplayer: failed to close audio playback stream");
1256 audioplayer::isplaying (
void)
1258 if (get_stream () ==
nullptr)
1262 err = Pa_IsStreamActive (stream);
1263 if (err != 0 && err != 1)
1264 error (
"audioplayer: checking stream activity status failed");
1272 audiorecorder (
void);
1273 ~audiorecorder (
void);
1276 double player_value (
void)
const {
return 0; }
1277 virtual double scalar_value (
bool =
false)
const {
return 0; }
1278 void print (std::ostream& os,
bool pr_as_read_syntax =
false);
1279 void print_raw (std::ostream& os,
bool pr_as_read_syntax)
const;
1283 bool is_defined (
void)
const {
return true; }
1287 void set_fs (
int fs);
1289 void set_nbits (
int nbits);
1290 int get_nbits (
void);
1291 PaSampleFormat get_sampleFormat (
void);
1292 void set_id (
int id);
1294 void set_channels (
int channels);
1295 int get_channels (
void);
1296 audio_type get_type (
void);
1298 void set_sample_number (
unsigned int sample);
1299 unsigned int get_sample_number (
void);
1300 unsigned int get_total_samples (
void);
1301 void set_end_sample (
unsigned int sample);
1302 unsigned int get_end_sample (
void);
1303 void reset_end_sample (
void);
1308 PaStream * get_stream (
void);
1311 audioplayer * getplayer (
void);
1312 bool isrecording (
void);
1313 audioplayer play (
void);
1315 void recordblocking (
float seconds);
1319 void append (
float sample_l,
float sample_r);
1328 unsigned int sample_number;
1329 unsigned int end_sample;
1333 std::vector<float>
left;
1334 std::vector<float> right;
1336 PaStreamParameters input_parameters;
1345 octave_record_callback (
const void *
input,
void *,
unsigned long frames,
1346 const PaStreamCallbackTimeInfo *,
1347 PaStreamCallbackFlags,
void *data)
1349 audiorecorder *recorder =
static_cast<audiorecorder *
> (data);
1352 error (
"audio recorder callback function called without recorder");
1354 int channels = recorder->get_channels ();
1356 Matrix sound (frames, 2);
1357 sound.
resize (frames, 2);
1359 if (recorder->get_sampleFormat () == bits_to_format (8))
1361 static double scale_factor =
std::pow (2.0, 7) - 1.0;
1363 const int8_t *input8 =
static_cast<const int8_t *
> (
input);
1365 for (
unsigned long i = 0; i < frames; i++)
1367 float sample_l = input8[i*channels] / scale_factor;
1368 float sample_r = input8[i*channels + (channels - 1)] / scale_factor;
1370 sound(i,0) = sample_l;
1371 sound(i,1) = sample_r;
1377 else if (recorder->get_sampleFormat () == bits_to_format (16)
1378 && recorder->get_nbits () == 8)
1380 static double scale_factor =
std::pow (2.0, 7) - 1.0;
1382 const int16_t *input16 =
static_cast<const int16_t *
> (
input);
1384 for (
unsigned long i = 0; i < frames; i++)
1386 float sample_l = (input16[i*channels] >> 8) / scale_factor;
1387 float sample_r = (input16[i*channels + (channels - 1)] >> 8)
1390 sound(i,0) = sample_l;
1391 sound(i,1) = sample_r;
1394 else if (recorder->get_sampleFormat () == bits_to_format (16))
1396 static double scale_factor =
std::pow (2.0, 15) - 1.0;
1398 const int16_t *input16 =
static_cast<const int16_t *
> (
input);
1400 for (
unsigned long i = 0; i < frames; i++)
1402 float sample_l = input16[i*channels] / scale_factor;
1403 float sample_r = input16[i*channels + (channels - 1)] / scale_factor;
1405 sound(i,0) = sample_l;
1406 sound(i,1) = sample_r;
1409 else if (recorder->get_sampleFormat () == bits_to_format (24))
1411 static double scale_factor =
std::pow (2.0, 23);
1415 const uint8_t *input24 =
static_cast<const uint8_t *
> (
input);
1417 int32_t sample_l32, sample_r32;
1419 uint8_t *sample_l =
reinterpret_cast<uint8_t *
> (&sample_l32);
1420 uint8_t *sample_r =
reinterpret_cast<uint8_t *
> (&sample_r32);
1422 for (
unsigned long i = 0; i < frames; i++)
1424 sample_l32 = sample_r32 = 0;
1425 for (
int j = 0; j < 3; j++)
1427 sample_l[j] = input24[i*channels*3 + j];
1428 sample_r[j] = input24[i*channels*3 + (channels - 1)*3 + j];
1431 if (sample_l32 & 0x00800000)
1432 sample_l32 |= 0xff000000;
1434 if (sample_r32 & 0x00800000)
1435 sample_r32 |= 0xff000000;
1437 sound(i,0) = sample_l32 / scale_factor;
1438 sound(i,1) = sample_r32 / scale_factor;
1445 return retval(0).int_value ();
1449 portaudio_record_callback (
const void *
input,
void *,
unsigned long frames,
1450 const PaStreamCallbackTimeInfo *,
1451 PaStreamCallbackFlags,
void *data)
1453 audiorecorder *recorder =
static_cast<audiorecorder *
> (data);
1456 error (
"audio recorder callback function called without recorder");
1458 int channels = recorder->get_channels ();
1460 if (recorder->get_sampleFormat () == bits_to_format (8))
1462 static float scale_factor =
std::pow (2.0f, 7) - 1.0f;
1464 const int8_t *input8 =
static_cast<const int8_t *
> (
input);
1466 for (
unsigned long i = 0; i < frames; i++)
1468 float sample_l = input8[i*channels] / scale_factor;
1469 float sample_r = input8[i*channels + (channels - 1)] / scale_factor;
1471 recorder->append (sample_l, sample_r);
1477 else if (recorder->get_sampleFormat () == bits_to_format (16)
1478 && recorder->get_nbits () == 8)
1480 static double scale_factor =
std::pow (2.0, 7) - 1.0;
1482 const int16_t *input16 =
static_cast<const int16_t *
> (
input);
1484 for (
unsigned long i = 0; i < frames; i++)
1486 float sample_l = (input16[i*channels] >> 8) / scale_factor;
1487 float sample_r = (input16[i*channels + (channels - 1)] >> 8)
1490 recorder->append (sample_l, sample_r);
1493 else if (recorder->get_sampleFormat () == bits_to_format (16))
1495 static float scale_factor =
std::pow (2.0f, 15) - 1.0f;
1497 const int16_t *input16 =
static_cast<const int16_t *
> (
input);
1499 for (
unsigned long i = 0; i < frames; i++)
1501 float sample_l = input16[i*channels] / scale_factor;
1502 float sample_r = input16[i*channels + (channels - 1)] / scale_factor;
1504 recorder->append (sample_l, sample_r);
1507 else if (recorder->get_sampleFormat () == bits_to_format (24))
1509 static float scale_factor =
std::pow (2.0f, 23);
1513 const uint8_t *input24 =
static_cast<const uint8_t *
> (
input);
1515 int32_t sample_l32, sample_r32;
1517 uint8_t *sample_l =
reinterpret_cast<uint8_t *
> (&sample_l32);
1518 uint8_t *sample_r =
reinterpret_cast<uint8_t *
> (&sample_r32);
1520 for (
unsigned long i = 0; i < frames; i++)
1522 sample_l32 = sample_r32 = 0;
1523 for (
int j = 0; j < 3; j++)
1525 sample_l[j] = input24[i*channels*3 + j];
1526 sample_r[j] = input24[i*channels*3 + (channels - 1)*3 + j];
1529 if (sample_l32 & 0x00800000)
1530 sample_l32 |= 0xff000000;
1532 if (sample_r32 & 0x00800000)
1533 sample_r32 |= 0xff000000;
1535 recorder->append (sample_l32 / scale_factor,
1536 sample_r32 / scale_factor);
1540 if (recorder->get_sample_number () >= recorder->get_end_sample ())
1547 safe_audiorecorder_stop (audiorecorder *recorder)
1552 audiorecorder::audiorecorder (
void)
1553 : octave_callback_function (nullptr),
1554 id (-1), fs (8000), nbits (8), channels (1), sample_number (0),
1555 end_sample (-1), tag (
""), y (), userdata (
Matrix ()),
1556 left (), right (), stream (nullptr), input_parameters (),
type ()
1559 audiorecorder::~audiorecorder (
void)
1564 "interrupting recording audiorecorder");
1570 audiorecorder::print (std::ostream& os,
bool pr_as_read_syntax)
1572 print_raw (os, pr_as_read_syntax);
1577 audiorecorder::print_raw (std::ostream& os,
bool)
const
1583 audiorecorder::init (
void)
1585 if (Pa_Initialize () != paNoError)
1586 error (
"audiorecorder: initialization error");
1588 if (Pa_GetDeviceCount () < 1)
1589 error (
"audiorecorder: no audio devices found or available");
1591 int device = get_id ();
1594 device = Pa_GetDefaultInputDevice ();
1596 input_parameters.device = device;
1597 input_parameters.channelCount = get_channels ();
1598 input_parameters.sampleFormat = bits_to_format (get_nbits ());
1603 if (get_nbits () == 8)
1604 input_parameters.sampleFormat = bits_to_format (16);
1606 const PaDeviceInfo *device_info = Pa_GetDeviceInfo (device);
1610 "invalid default audio device ID = %d", device);
1612 input_parameters.suggestedLatency
1613 = (device_info ? device_info->defaultHighInputLatency : -1);
1615 input_parameters.hostApiSpecificStreamInfo =
nullptr;
1619 audiorecorder::set_fs (
int fs_arg)
1625 audiorecorder::get_fs (
void)
1631 audiorecorder::set_nbits (
int nbits_arg)
1637 audiorecorder::get_nbits (
void)
1643 audiorecorder::get_sampleFormat (
void)
1645 return input_parameters.sampleFormat;
1649 audiorecorder::set_id (
int id_arg)
1655 audiorecorder::get_id (
void)
1661 audiorecorder::set_channels (
int channels_arg)
1663 assert (channels_arg == 1 || channels_arg == 2);
1664 channels = channels_arg;
1668 audiorecorder::get_channels (
void)
1674 audiorecorder::get_type (
void)
1680 audiorecorder::set_sample_number (
unsigned int sample_number_arg)
1682 sample_number = sample_number_arg;
1686 audiorecorder::get_sample_number (
void)
1688 return sample_number;
1692 audiorecorder::get_total_samples (
void)
1694 return left.size ();
1698 audiorecorder::set_end_sample (
unsigned int end_sample_arg)
1700 end_sample = end_sample_arg;
1704 audiorecorder::get_end_sample (
void)
1710 audiorecorder::reset_end_sample (
void)
1712 set_end_sample (
left.size ());
1716 audiorecorder::set_tag (
const charMatrix& tag_arg)
1722 audiorecorder::get_tag (
void)
1728 audiorecorder::set_userdata (
const octave_value& userdata_arg)
1730 userdata = userdata_arg;
1734 audiorecorder::get_userdata (
void)
1740 audiorecorder::getaudiodata (
void)
1744 unsigned int ls =
left.size ();
1747 for (
unsigned int i = 0; i < ls; i++)
1749 audio(0,i) =
left[i];
1750 audio(1,i) = right[i];
1757 audiorecorder::getplayer (
void)
1759 audioplayer *player =
new audioplayer ();
1761 player->set_y (getaudiodata ());
1762 player->set_fs (get_fs ());
1763 player->set_nbits (get_nbits ());
1770 audiorecorder::isrecording (
void)
1772 if (get_stream () ==
nullptr)
1776 err = Pa_IsStreamActive (stream);
1777 if (err != 0 && err != 1)
1778 error (
"audiorecorder: checking stream activity status failed");
1784 audiorecorder::record (
void)
1792 const unsigned int buffer_size = get_fs () / 20;
1795 if (octave_callback_function !=
nullptr)
1797 err = Pa_OpenStream (&stream, &(input_parameters),
nullptr,
1798 get_fs (), buffer_size, paClipOff,
1799 octave_record_callback,
this);
1803 err = Pa_OpenStream (&stream, &(input_parameters),
nullptr,
1804 get_fs (), buffer_size, paClipOff,
1805 portaudio_record_callback,
this);
1807 if (err != paNoError)
1808 error (
"audiorecorder: unable to open audio recording stream");
1810 err = Pa_StartStream (stream);
1811 if (err != paNoError)
1812 error (
"audiorecorder: unable to start audio recording stream");
1816 audiorecorder::recordblocking (
float seconds)
1824 const unsigned int buffer_size = get_fs () / 20;
1828 err = Pa_OpenStream (&stream, &(input_parameters),
nullptr,
1829 get_fs (), buffer_size, paClipOff,
nullptr,
this);
1830 if (err != paNoError)
1831 error (
"audiorecorder: unable to open audio recording stream");
1833 err = Pa_StartStream (stream);
1834 if (err != paNoError)
1835 error (
"audiorecorder: unable to start audio recording stream");
1837 unsigned int frames = seconds * get_fs ();
1841 frame.
add_fcn (safe_audiorecorder_stop,
this);
1843 for (
unsigned int i = 0; i < frames; i += buffer_size)
1847 Pa_ReadStream (get_stream (), buffer, buffer_size);
1849 if (octave_callback_function !=
nullptr)
1850 octave_record_callback (buffer,
nullptr, buffer_size,
nullptr, 0,
this);
1852 portaudio_record_callback (buffer,
nullptr, buffer_size,
nullptr, 0,
this);
1857 audiorecorder::pause (
void)
1859 if (get_stream () ==
nullptr)
1863 err = Pa_StopStream (stream);
1864 if (err != paNoError)
1865 error (
"audiorecorder: unable to stop audio recording stream");
1869 audiorecorder::resume (
void)
1871 if (get_stream () ==
nullptr)
1875 err = Pa_StartStream (stream);
1876 if (err != paNoError)
1877 error (
"audiorecorder: unable to start audio recording stream");
1881 audiorecorder::stop (
void)
1883 if (get_stream () ==
nullptr)
1887 if (! Pa_IsStreamStopped (get_stream ()))
1889 err = Pa_AbortStream (get_stream ());
1890 if (err != paNoError)
1891 error (
"audioplayer: unable to stop audio playback stream");
1894 err = Pa_CloseStream (stream);
1895 if (err != paNoError)
1896 error (
"audiorecorder: unable to close audio recording stream");
1898 set_sample_number (0);
1899 reset_end_sample ();
1904 audiorecorder::append (
float sample_l,
float sample_r)
1906 left.push_back (sample_l);
1907 right.push_back (sample_r);
1908 set_sample_number (get_sample_number () + 1);
1912 audiorecorder::get_stream (
void)
1929 #if defined (HAVE_PORTAUDIO)
1933 int nargin = args.length ();
1935 audiorecorder *recorder =
new audiorecorder ();
1939 bool is_function = (args(0).is_string () || args(0).is_function_handle ()
1940 || args(0).is_inline_function ());
1943 error (
"audiorecorder: callbacks not yet implemented");
1948 recorder->set_fs (args(0).int_value ());
1949 recorder->set_nbits (args(1).int_value ());
1950 recorder->set_channels (args(2).int_value ());
1955 recorder->set_id (args(3).int_value ());
1962 octave_unused_parameter (interp);
1963 octave_unused_parameter (args);
1966 "audio playback and recording through PortAudio");
1972 #if defined (HAVE_PORTAUDIO)
1974 static audiorecorder *
1983 audiorecorder *rec =
dynamic_cast<audiorecorder *
> (ncrep);
1985 error (
"audiodevinfo.cc (get_recorder): dynamic_cast to audiorecorder failed");
2000 #if defined (HAVE_PORTAUDIO)
2001 retval = get_recorder (interp, args(0))->getaudiodata ();
2003 octave_unused_parameter (interp);
2004 octave_unused_parameter (args);
2007 "audio playback and recording through PortAudio");
2021 #if defined (HAVE_PORTAUDIO)
2022 retval = get_recorder (interp, args(0))->get_channels ();
2024 octave_unused_parameter (interp);
2025 octave_unused_parameter (args);
2028 "audio playback and recording through PortAudio");
2042 #if defined (HAVE_PORTAUDIO)
2043 retval = get_recorder (interp, args(0))->get_fs ();
2045 octave_unused_parameter (interp);
2046 octave_unused_parameter (args);
2049 "audio playback and recording through PortAudio");
2063 #if defined (HAVE_PORTAUDIO)
2064 retval = get_recorder (interp, args(0))->get_id ();
2066 octave_unused_parameter (interp);
2067 octave_unused_parameter (args);
2070 "audio playback and recording through PortAudio");
2084 #if defined (HAVE_PORTAUDIO)
2085 retval = get_recorder (interp, args(0))->get_nbits ();
2087 octave_unused_parameter (interp);
2088 octave_unused_parameter (args);
2091 "audio playback and recording through PortAudio");
2097 DEFMETHOD_DLD (__recorder_get_sample_number__, interp, args, ,
2105 #if defined (HAVE_PORTAUDIO)
2106 retval = get_recorder (interp, args(0))->get_sample_number ();
2108 octave_unused_parameter (interp);
2109 octave_unused_parameter (args);
2112 "audio playback and recording through PortAudio");
2126 #if defined (HAVE_PORTAUDIO)
2127 retval = get_recorder (interp, args(0))->get_tag ();
2129 octave_unused_parameter (interp);
2130 octave_unused_parameter (args);
2133 "audio playback and recording through PortAudio");
2139 DEFMETHOD_DLD (__recorder_get_total_samples__, interp, args, ,
2147 #if defined (HAVE_PORTAUDIO)
2148 retval = get_recorder (interp, args(0))->get_total_samples ();
2150 octave_unused_parameter (interp);
2151 octave_unused_parameter (args);
2154 "audio playback and recording through PortAudio");
2168 #if defined (HAVE_PORTAUDIO)
2169 retval = get_recorder (interp, args(0))->get_userdata ();
2171 octave_unused_parameter (interp);
2172 octave_unused_parameter (args);
2175 "audio playback and recording through PortAudio");
2189 #if defined (HAVE_PORTAUDIO)
2190 retval = get_recorder (interp, args(0))->isrecording ();
2192 octave_unused_parameter (interp);
2193 octave_unused_parameter (args);
2196 "audio playback and recording through PortAudio");
2208 #if defined (HAVE_PORTAUDIO)
2209 get_recorder (interp, args(0))->pause ();
2212 octave_unused_parameter (interp);
2213 octave_unused_parameter (args);
2216 "audio playback and recording through PortAudio");
2226 #if defined (HAVE_PORTAUDIO)
2227 float seconds = args(1).float_value ();
2228 get_recorder (interp, args(0))->recordblocking (seconds);
2231 octave_unused_parameter (interp);
2232 octave_unused_parameter (args);
2235 "audio playback and recording through PortAudio");
2246 #if defined (HAVE_PORTAUDIO)
2247 audiorecorder *recorder = get_recorder (interp, args(0));
2249 if (args.length () == 2)
2250 recorder->set_end_sample (args(1).int_value () * recorder->get_fs ());
2252 recorder->record ();
2255 octave_unused_parameter (interp);
2256 octave_unused_parameter (args);
2259 "audio playback and recording through PortAudio");
2269 #if defined (HAVE_PORTAUDIO)
2270 if (args.length () == 1)
2271 get_recorder (interp, args(0))->resume ();
2274 octave_unused_parameter (interp);
2275 octave_unused_parameter (args);
2278 "audio playback and recording through PortAudio");
2288 #if defined (HAVE_PORTAUDIO)
2289 if (args.length () == 2)
2290 get_recorder (interp, args(0))->set_fs (args(1).int_value ());
2293 octave_unused_parameter (interp);
2294 octave_unused_parameter (args);
2297 "audio playback and recording through PortAudio");
2307 #if defined (HAVE_PORTAUDIO)
2308 if (args.length () == 2)
2309 get_recorder (interp, args(0))->set_tag (args(1).char_matrix_value ());
2312 octave_unused_parameter (interp);
2313 octave_unused_parameter (args);
2316 "audio playback and recording through PortAudio");
2326 #if defined (HAVE_PORTAUDIO)
2327 if (args.length () == 2)
2328 get_recorder (interp, args(0))->set_userdata (args(1));
2331 octave_unused_parameter (interp);
2332 octave_unused_parameter (args);
2335 "audio playback and recording through PortAudio");
2345 #if defined (HAVE_PORTAUDIO)
2346 if (args.length () == 1)
2347 get_recorder (interp, args(0))->stop ();
2350 octave_unused_parameter (interp);
2351 octave_unused_parameter (args);
2354 "audio playback and recording through PortAudio");
2368 #if defined (HAVE_PORTAUDIO)
2371 audioplayer *recorder =
new audioplayer ();
2373 bool is_function = (args(0).is_string () || args(0).is_function_handle ()
2374 || args(0).is_inline_function ());
2377 error (
"audioplayer: callbacks not yet implemented");
2379 recorder->set_y (args(0));
2380 recorder->set_fs (args(1).int_value ());
2382 if (args.length () > 2)
2385 int nbits = args(2).int_value ();
2386 if (nbits != 8 && nbits != 16 && nbits != 24)
2387 error (
"audioplayer: NBITS must be 8, 16, or 24");
2389 switch (args.length ())
2392 recorder->set_nbits (nbits);
2396 recorder->set_nbits (nbits);
2397 recorder->set_id (args(3).int_value ());
2403 recorder->init_fn ();
2409 octave_unused_parameter (interp);
2410 octave_unused_parameter (args);
2413 "audio playback and recording through PortAudio");
2419 #if defined (HAVE_PORTAUDIO)
2421 static audioplayer *
2430 audioplayer *pl =
dynamic_cast<audioplayer *
> (ncrep);
2432 error (
"audiodevinfo.cc get_player: dynamic_cast to audioplayer failed");
2447 #if defined (HAVE_PORTAUDIO)
2448 if (args.length () == 1)
2449 retval = get_player (interp, args(0))->get_channels ();
2451 octave_unused_parameter (interp);
2452 octave_unused_parameter (args);
2455 "audio playback and recording through PortAudio");
2469 #if defined (HAVE_PORTAUDIO)
2470 if (args.length () == 1)
2471 retval = get_player (interp, args(0))->get_fs ();
2473 octave_unused_parameter (interp);
2474 octave_unused_parameter (args);
2477 "audio playback and recording through PortAudio");
2491 #if defined (HAVE_PORTAUDIO)
2492 if (args.length () == 1)
2493 retval = get_player (interp, args(0))->get_id ();
2495 octave_unused_parameter (interp);
2496 octave_unused_parameter (args);
2499 "audio playback and recording through PortAudio");
2513 #if defined (HAVE_PORTAUDIO)
2514 if (args.length () == 1)
2515 retval = get_player (interp, args(0))->get_nbits ();
2517 octave_unused_parameter (interp);
2518 octave_unused_parameter (args);
2521 "audio playback and recording through PortAudio");
2527 DEFMETHOD_DLD (__player_get_sample_number__, interp, args, ,
2535 #if defined (HAVE_PORTAUDIO)
2536 if (args.length () == 1)
2537 retval = get_player (interp, args(0))->get_sample_number ();
2539 octave_unused_parameter (interp);
2540 octave_unused_parameter (args);
2543 "audio playback and recording through PortAudio");
2557 #if defined (HAVE_PORTAUDIO)
2558 if (args.length () == 1)
2559 retval = get_player (interp, args(0))->get_tag ();
2561 octave_unused_parameter (interp);
2562 octave_unused_parameter (args);
2565 "audio playback and recording through PortAudio");
2571 DEFMETHOD_DLD (__player_get_total_samples__, interp, args, ,
2579 #if defined (HAVE_PORTAUDIO)
2580 if (args.length () == 1)
2581 retval = get_player (interp, args(0))->get_total_samples ();
2583 octave_unused_parameter (interp);
2584 octave_unused_parameter (args);
2587 "audio playback and recording through PortAudio");
2601 #if defined (HAVE_PORTAUDIO)
2602 if (args.length () == 1)
2603 retval = get_player (interp, args(0))->get_userdata ();
2605 octave_unused_parameter (interp);
2606 octave_unused_parameter (args);
2609 "audio playback and recording through PortAudio");
2623 #if defined (HAVE_PORTAUDIO)
2624 if (args.length () == 1)
2625 retval = get_player (interp, args(0))->isplaying ();
2627 octave_unused_parameter (interp);
2628 octave_unused_parameter (args);
2631 "audio playback and recording through PortAudio");
2643 #if defined (HAVE_PORTAUDIO)
2644 if (args.length () == 1)
2645 get_player (interp, args(0))->pause ();
2648 octave_unused_parameter (interp);
2649 octave_unused_parameter (args);
2652 "audio playback and recording through PortAudio");
2664 #if defined (HAVE_PORTAUDIO)
2666 audioplayer *player = get_player (interp, args(0));
2668 if (args.length () == 1)
2670 player->playblocking ();
2672 else if (args.length () == 2)
2674 if (args(1).is_matrix_type ())
2676 RowVector range = args(1).row_vector_value ();
2678 unsigned int start = range.
elem (0) - 1;
2679 unsigned int end = range.
elem (1) - 1;
2681 if (start > player->get_total_samples ()
2682 || start > end || end > player->get_total_samples ())
2683 error (
"audioplayer: invalid range specified for playback");
2685 player->set_sample_number (start);
2686 player->set_end_sample (end);
2690 unsigned int start = args(1).int_value () - 1;
2692 if (start > player->get_total_samples ())
2693 error (
"audioplayer: invalid range specified for playback");
2695 player->set_sample_number (start);
2698 player->playblocking ();
2703 octave_unused_parameter (interp);
2704 octave_unused_parameter (args);
2707 "audio playback and recording through PortAudio");
2719 #if defined (HAVE_PORTAUDIO)
2721 if (args.length () == 1)
2723 get_player (interp, args(0))->play ();
2725 else if (args.length () == 2)
2727 audioplayer *player = get_player (interp, args(0));
2729 if (args(1).is_matrix_type ())
2731 RowVector range = args(1).row_vector_value ();
2733 unsigned int start = range.
elem (0) - 1;
2734 unsigned int end = range.
elem (1) - 1;
2736 if (start > player->get_total_samples ()
2737 || start > end || end > player->get_total_samples ())
2738 error (
"audioplayer: invalid range specified for playback");
2740 player->set_sample_number (start);
2741 player->set_end_sample (end);
2745 unsigned int start = args(1).int_value () - 1;
2747 if (start > player->get_total_samples ())
2748 error (
"audioplayer: invalid range specified for playback");
2750 player->set_sample_number (start);
2758 octave_unused_parameter (interp);
2759 octave_unused_parameter (args);
2762 "audio playback and recording through PortAudio");
2772 #if defined (HAVE_PORTAUDIO)
2773 if (args.length () == 1)
2774 get_player (interp, args(0))->resume ();
2777 octave_unused_parameter (interp);
2778 octave_unused_parameter (args);
2781 "audio playback and recording through PortAudio");
2791 #if defined (HAVE_PORTAUDIO)
2792 if (args.length () == 2)
2793 get_player (interp, args(0))->set_fs (args(1).int_value ());
2796 octave_unused_parameter (interp);
2797 octave_unused_parameter (args);
2800 "audio playback and recording through PortAudio");
2810 #if defined (HAVE_PORTAUDIO)
2811 if (args.length () == 2)
2812 get_player (interp, args(0))->set_tag (args(1).char_matrix_value ());
2815 octave_unused_parameter (interp);
2816 octave_unused_parameter (args);
2819 "audio playback and recording through PortAudio");
2829 #if defined (HAVE_PORTAUDIO)
2830 if (args.length () == 2)
2831 get_player (interp, args(0))->set_userdata (args(1));
2834 octave_unused_parameter (interp);
2835 octave_unused_parameter (args);
2838 "audio playback and recording through PortAudio");
2848 #if defined (HAVE_PORTAUDIO)
2849 if (args.length () == 1)
2850 get_player (interp, args(0))->stop ();
2853 octave_unused_parameter (interp);
2854 octave_unused_parameter (args);
2857 "audio playback and recording through PortAudio");
octave_idx_type columns(void) const
T & elem(octave_idx_type n)
Size of the specified dimension.
const T * data(void) const
Size of the specified dimension.
octave_idx_type rows(void) const
Matrix transpose(void) const
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
ColumnVector column(octave_idx_type i) const
Vector representing the dimensions (size) of an Array.
void add_fcn(void(*fcn)(Params...), Args &&... args)
void mlock(bool skip_first=false) const
virtual bool is_constant(void) const
virtual bool print_as_scalar(void) const
virtual void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
virtual double scalar_value(bool frc_str_conv=false) const
virtual void print(std::ostream &os, bool pr_as_read_syntax=false)
virtual bool is_defined(void) const
void setfield(const std::string &key, const Cell &val)
void setfield(const std::string &key, const octave_value &val)
const octave_base_value & get_rep(void) const
bool is_int8_type(void) const
bool is_int16_type(void) const
bool is_uint8_type(void) const
Matrix matrix_value(bool frc_str_conv=false) const
#define DEFUN_DLD(name, args_name, nargout_name, doc)
Macro to define an at run time dynamically loadable builtin function.
#define DEFMETHOD_DLD(name, interp_name, args_name, nargout_name, doc)
Macro to define an at run time dynamically loadable builtin method.
OCTINTERP_API void print_usage(void)
void warning_with_id(const char *id, const char *fmt,...)
void error(const char *fmt,...)
void err_disabled_feature(const std::string &fcn, const std::string &feature, const std::string &pkg)
ColumnVector transform(const Matrix &m, double x, double y, double z)
bool words_big_endian(void)
octave_value_list feval(const char *name, const octave_value_list &args, int nargout)
Evaluate an Octave function (built-in or interpreted) and return the list of result values.
size_t format(std::ostream &os, const char *fmt,...)
octave_int< T > pow(const octave_int< T > &a, const octave_int< T > &b)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
static int input(yyscan_t yyscanner)
#define DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
octave_value::octave_value(const Array< char > &chm, char type) return retval
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.