26 #if defined (HAVE_CONFIG_H)
53 #if defined (HAVE_PORTAUDIO)
54 # include <portaudio.h>
59 #if defined (HAVE_PORTAUDIO)
62 bits_to_format (
int bits)
120 #if defined (HAVE_PORTAUDIO)
122 int nargin = args.length ();
131 PaError err = Pa_Initialize ();
133 if (err != paNoError)
134 error (
"audiodevinfo: PortAudio initialization failed");
136 int num_devices = Pa_GetDeviceCount ();
142 numinput = numoutput = 0;
143 for (
int i = 0; i < num_devices; i++)
145 const PaDeviceInfo *device_info = Pa_GetDeviceInfo (i);
150 "invalid audio device ID = %d", i);
154 if (device_info->maxInputChannels != 0)
157 if (device_info->maxOutputChannels != 0)
170 for (
int i = 0; i < num_devices; i++)
172 const PaDeviceInfo *device_info = Pa_GetDeviceInfo (i);
177 "invalid audio device ID = %d", i);
181 const PaHostApiInfo *api_info = Pa_GetHostApiInfo (device_info->hostApi);
183 const char *driver = (api_info ? api_info->name :
"");
186 sprintf (name,
"%s (%s)", device_info->name, driver);
188 if (device_info->maxInputChannels != 0)
190 input_name(idx_i) = name;
191 input_driver_version(idx_i) = driver;
196 if (device_info->maxOutputChannels != 0)
198 output_name(idx_o) = name;
199 output_driver_version(idx_o) = driver;
200 output_id(idx_o) = i;
206 inputdev.
setfield (
"Name", input_name);
207 inputdev.
setfield (
"DriverVersion", input_driver_version);
209 outputdev.
setfield (
"Name", output_name);
210 outputdev.
setfield (
"DriverVersion", output_driver_version);
211 outputdev.
setfield (
"ID", output_id);
212 devinfo.
setfield (
"input", inputdev);
213 devinfo.
setfield (
"output", outputdev);
223 else if (nargin == 1)
225 if (args(0).int_value () == 0)
227 else if (args(0).int_value () == 1)
230 error (
"audiodevinfo: specify 0 for output and 1 for input devices");
233 else if (nargin == 2)
236 int outin = args(0).int_value ();
237 if (args(1).is_string ())
239 std::string name = args(1).string_value ();
242 for (
int i = 0; i < numoutput; i++)
244 if (output_name(i).string_value () == name)
246 retval = output_id(i);
254 for (
int i = 0; i < numinput; i++)
256 if (input_name(i).string_value () == name)
258 retval = input_id(i);
265 error (
"audiodevinfo: specify 0 for output and 1 for input devices");
271 for (
int i = 0; i < numoutput; i++)
273 if (output_id(i).int_value () == args(1).int_value ())
275 retval = output_name(i);
283 for (
int i = 0; i < numinput; i++)
285 if (input_id(i).int_value () == args(1).int_value ())
287 retval = input_name(i);
294 error (
"audiodevinfo: specify 0 for output and 1 for input devices");
298 error (
"audiodevinfo: no device found for the specified criteria");
301 else if (nargin == 3)
304 int outin = args(0).int_value ();
305 int id = args(1).int_value ();
307 std::string arg3 = args(2).string_value ();
308 std::transform (arg3.begin (), arg3.end (), arg3.begin (), tolower);
309 if (arg3 !=
"driverversion")
310 error (R
"(audiodevinfo: third argument must be "DriverVersion")");
314 for (
int i = 0; i < numoutput; i++)
316 if (output_id(i).int_value () ==
id)
319 retval = output_driver_version(i);
326 for (
int i = 0; i < numinput; i++)
328 if (input_id(i).int_value () ==
id)
331 retval = input_driver_version(i);
337 error (
"audiodevinfo: specify 0 for output and 1 for input devices");
340 error (
"audiodevinfo: no device found for the specified criteria");
343 else if (nargin == 4)
345 int io = args(0).int_value ();
346 int rate = args(1).int_value ();
347 int bits = args(2).int_value ();
348 int chans = args(3).int_value ();
350 for (
int i = 0; i < num_devices; i++)
352 PaStreamParameters stream_parameters;
353 stream_parameters.device = i;
354 stream_parameters.channelCount = chans;
355 PaSampleFormat
format = bits_to_format (bits);
358 stream_parameters.sampleFormat =
format;
360 error (
"audiodevinfo: invalid bits per sample format");
362 const PaDeviceInfo *device_info = Pa_GetDeviceInfo (i);
367 "invalid audio device ID = %d", i);
371 stream_parameters.suggestedLatency
372 = device_info->defaultLowInputLatency;
374 stream_parameters.hostApiSpecificStreamInfo =
nullptr;
378 if (device_info->maxOutputChannels < chans)
381 err = Pa_IsFormatSupported (
nullptr, &stream_parameters, rate);
383 if (err == paFormatIsSupported)
391 if (device_info->maxInputChannels < chans)
394 err = Pa_IsFormatSupported (&stream_parameters,
nullptr, rate);
395 if (err == paFormatIsSupported)
405 else if (nargin == 5)
408 int id = args(1).int_value ();
409 int rate = args(2).int_value ();
410 int bits = args(3).int_value ();
411 int chans = args(4).int_value ();
412 PaStreamParameters stream_parameters;
413 stream_parameters.device = id;
414 stream_parameters.channelCount = chans;
415 PaSampleFormat
format = bits_to_format (bits);
417 stream_parameters.sampleFormat =
format;
419 error (
"audiodevinfo: invalid bits per sample format");
421 const PaDeviceInfo *device_info = Pa_GetDeviceInfo (
id);
424 error (
"audiodevinfo: invalid audio device ID = %d",
id);
426 stream_parameters.suggestedLatency
427 = device_info->defaultLowInputLatency;
429 stream_parameters.hostApiSpecificStreamInfo =
nullptr;
432 if (device_info->maxOutputChannels < chans)
437 err = Pa_IsFormatSupported (
nullptr, &stream_parameters, rate);
438 if (err == paFormatIsSupported)
446 if (device_info->maxInputChannels < chans)
451 err = Pa_IsFormatSupported (&stream_parameters,
nullptr, rate);
452 if (err == paFormatIsSupported)
459 error (
"audiodevinfo: specify 0 for output and 1 for input devices");
467 octave_unused_parameter (args);
470 "audio playback and recording through PortAudio");
517 #if defined (HAVE_PORTAUDIO)
519 enum audio_type { TYPE_INT8, TYPE_UINT8, TYPE_UINT16, TYPE_DOUBLE };
528 double player_value (
void)
const {
return 0; }
529 virtual double scalar_value (
bool =
false)
const {
return 0; }
530 void print (std::ostream& os,
bool pr_as_read_syntax =
false);
531 void print_raw (std::ostream& os,
bool pr_as_read_syntax)
const;
542 void set_y (std::string fcn);
546 void set_fs (
int fs);
548 void set_nbits (
int nbits);
549 int get_nbits (
void);
550 void set_id (
int id);
552 int get_channels (
void);
553 audio_type get_type (
void);
555 void set_sample_number (
unsigned int sample);
556 unsigned int get_sample_number (
void);
557 unsigned int get_total_samples (
void);
558 void set_end_sample (
unsigned int sample);
559 unsigned int get_end_sample (
void);
560 void reset_end_sample (
void);
565 PaStream * get_stream (
void);
568 void playblocking (
void);
572 bool isplaying (
void);
581 unsigned int sample_number;
582 unsigned int end_sample;
589 PaStreamParameters output_parameters;
598 octave_play_callback (
const void *,
void *output,
unsigned long frames,
599 const PaStreamCallbackTimeInfo *,
600 PaStreamCallbackFlags,
void *data)
602 audioplayer *player =
static_cast<audioplayer *
> (data);
605 error (
"audioplayer callback function called without player");
608 =
feval (player->octave_callback_function,
609 ovl (
static_cast<double> (frames)), 1);
612 error (
"audioplayer callback function failed");
614 const Matrix sound = retval(0).matrix_value ();
615 int return_status = retval(1).int_value ();
617 if (frames - sound.
rows () != 0 || sound.
columns () < 1
619 error (
"audioplayer callback function failed");
627 ? sound_l : sound.
column (1));
629 const double *p_l = sound_l.
data ();
630 const double *p_r = sound_r.
data ();
632 switch (player->get_nbits ())
636 static double scale_factor =
std::pow (2.0, 7) - 1.0;
638 int8_t *buffer =
static_cast<int8_t *
> (output);
640 for (
unsigned long i = 0; i < frames; i++)
642 buffer[2*i] = p_l[i] * scale_factor;
643 buffer[2*i+1] = p_r[i] * scale_factor;
650 static double scale_factor =
std::pow (2.0, 15) - 1.0;
652 int16_t *buffer =
static_cast<int16_t *
> (output);
654 for (
unsigned long i = 0; i < frames; i++)
656 buffer[2*i] = p_l[i] * scale_factor;
657 buffer[2*i+1] = p_r[i] * scale_factor;
664 static double scale_factor =
std::pow (2.0, 23) - 1.0;
668 uint8_t *buffer =
static_cast<uint8_t *
> (output);
670 for (
unsigned long i = 0; i < frames; i++)
672 int32_t sample_l = p_l[i];
673 int32_t sample_r = p_r[i];
675 sample_l &= 0x00ffffff;
676 sample_r &= 0x00ffffff;
678 uint8_t *_sample_l =
reinterpret_cast<uint8_t *
> (&sample_l);
679 uint8_t *_sample_r =
reinterpret_cast<uint8_t *
> (&sample_r);
681 unsigned long offset = i * 6;
683 buffer[offset+0] = _sample_l[0+big_endian] * scale_factor;
684 buffer[offset+1] = _sample_l[1+big_endian] * scale_factor;
685 buffer[offset+2] = _sample_l[2+big_endian] * scale_factor;
687 buffer[offset+3] = _sample_r[0+big_endian] * scale_factor;
688 buffer[offset+4] = _sample_r[1+big_endian] * scale_factor;
689 buffer[offset+5] = _sample_r[2+big_endian] * scale_factor;
695 error (
"invalid bit depth in audioplayer callback function");
698 return return_status;
702 portaudio_play_callback (
const void *,
void *output,
unsigned long frames,
703 const PaStreamCallbackTimeInfo *,
704 PaStreamCallbackFlags,
void *data)
706 audioplayer *player =
static_cast<audioplayer *
> (data);
709 error (
"audioplayer callback function called without player");
716 const RowVector sound_l = player->get_left ();
717 const RowVector sound_r = player->get_right ();
719 const double *pl = sound_l.
data ();
720 const double *pr = sound_r.
data ();
722 if (player->get_type () == TYPE_DOUBLE)
724 switch (player->get_nbits ())
728 static double scale_factor =
std::pow (2.0, 7) - 1.0;
730 int8_t *buffer =
static_cast<int8_t *
> (output);
732 for (
unsigned long j = 0; j < frames; j++)
734 unsigned int sample_number = player->get_sample_number ();
736 if (sample_number >= player->get_end_sample ())
739 unsigned long offset = j * 2;
741 buffer[offset+0] = pl[sample_number] * scale_factor;
742 buffer[offset+1] = pr[sample_number] * scale_factor;
744 player->set_sample_number (sample_number + 1);
751 static double scale_factor =
std::pow (2.0, 15) - 1.0;
753 int16_t *buffer =
static_cast<int16_t *
> (output);
755 for (
unsigned long j = 0; j < frames; j++)
757 unsigned int sample_number = player->get_sample_number ();
759 if (sample_number >= player->get_end_sample ())
762 unsigned long offset = j * 2;
764 buffer[offset+0] = pl[sample_number] * scale_factor;
765 buffer[offset+1] = pr[sample_number] * scale_factor;
767 player->set_sample_number (sample_number + 1);
774 static double scale_factor =
std::pow (2.0, 23) - 1.0;
778 uint8_t *buffer =
static_cast<uint8_t *
> (output);
780 for (
unsigned long j = 0; j < frames; j++)
782 unsigned int sample_number = player->get_sample_number ();
784 if (sample_number >= player->get_end_sample ())
787 int32_t sample_l = pl[sample_number] * scale_factor;
788 int32_t sample_r = pr[sample_number] * scale_factor;
790 sample_l &= 0x00ffffff;
791 sample_r &= 0x00ffffff;
793 uint8_t *_sample_l =
reinterpret_cast<uint8_t *
> (&sample_l);
794 uint8_t *_sample_r =
reinterpret_cast<uint8_t *
> (&sample_r);
796 unsigned long offset = j * 6;
798 buffer[offset+0] = _sample_l[0+big_endian];
799 buffer[offset+1] = _sample_l[1+big_endian];
800 buffer[offset+2] = _sample_l[2+big_endian];
802 buffer[offset+3] = _sample_r[0+big_endian];
803 buffer[offset+4] = _sample_r[1+big_endian];
804 buffer[offset+5] = _sample_r[2+big_endian];
806 player->set_sample_number (sample_number + 1);
812 error (
"invalid bit depth in audioplayer callback function");
815 else if (player->get_type () == TYPE_INT8)
817 int8_t *buffer =
static_cast<int8_t *
> (output);
819 for (
unsigned long j = 0; j < frames; j++)
821 unsigned int sample_number = player->get_sample_number ();
823 if (sample_number >= player->get_end_sample ())
826 unsigned long offset = j * 2;
828 buffer[offset+0] = pl[sample_number];
829 buffer[offset+1] = pr[sample_number];
831 player->set_sample_number (sample_number + 1);
834 else if (player->get_type () == TYPE_UINT8)
836 uint8_t *buffer =
static_cast<uint8_t *
> (output);
838 for (
unsigned long j = 0; j < frames; j++)
840 unsigned int sample_number = player->get_sample_number ();
842 if (sample_number >= player->get_end_sample ())
845 unsigned long offset = j * 2;
847 buffer[offset+0] = pl[sample_number];
848 buffer[offset+1] = pr[sample_number];
850 player->set_sample_number (sample_number + 1);
853 else if (player->get_type () == TYPE_UINT16)
855 int16_t *buffer =
static_cast<int16_t *
> (output);
857 for (
unsigned long j = 0; j < frames; j++)
859 unsigned int sample_number = player->get_sample_number ();
861 if (sample_number >= player->get_end_sample ())
864 unsigned long offset = j * 2;
866 buffer[offset+0] = pl[sample_number];
867 buffer[offset+1] = pr[sample_number];
869 player->set_sample_number (sample_number + 1);
876 audioplayer::audioplayer (
void)
877 : octave_callback_function (nullptr),
878 id (-1), fs (0), nbits (16), channels (0), sample_number (0),
879 end_sample (-1), tag (
""), y (), userdata (
Matrix ()),
880 left (), right (),
stream (nullptr), output_parameters (), type ()
883 audioplayer::~audioplayer (
void)
888 "interrupting audioplayer during playback");
894 audioplayer::print (std::ostream& os,
bool pr_as_read_syntax)
896 print_raw (os, pr_as_read_syntax);
901 audioplayer::print_raw (std::ostream& os,
bool)
const
907 audioplayer::init_fn (
void)
909 if (Pa_Initialize () != paNoError)
910 error (
"audioplayer: initialization error");
912 if (Pa_GetDeviceCount () < 1)
913 error (
"audioplayer: no audio devices found or available");
915 int device = get_id ();
918 device = Pa_GetDefaultOutputDevice ();
920 output_parameters.device = device;
921 output_parameters.channelCount = 2;
922 output_parameters.sampleFormat = bits_to_format (get_nbits ());
924 const PaDeviceInfo *device_info = Pa_GetDeviceInfo (device);
928 "invalid default audio device ID = %d", device);
930 output_parameters.suggestedLatency
931 = (device_info ? device_info->defaultHighOutputLatency : -1);
933 output_parameters.hostApiSpecificStreamInfo =
nullptr;
937 audioplayer::init (
void)
945 if (Pa_Initialize () != paNoError)
946 error (
"audioplayer: initialization error");
948 if (Pa_GetDeviceCount () < 1)
949 error (
"audioplayer: no audio devices found or available");
951 int device = get_id ();
954 device = Pa_GetDefaultOutputDevice ();
956 output_parameters.device = device;
957 output_parameters.channelCount = 2;
959 if (type == TYPE_DOUBLE)
960 output_parameters.sampleFormat = bits_to_format (get_nbits ());
961 else if (type == TYPE_INT8)
962 output_parameters.sampleFormat = paInt8;
963 else if (type == TYPE_UINT8)
964 output_parameters.sampleFormat = paUInt8;
965 else if (type == TYPE_UINT16)
966 output_parameters.sampleFormat = paInt16;
968 const PaDeviceInfo *device_info = Pa_GetDeviceInfo (device);
972 "invalid default audio device ID = %d", device);
974 output_parameters.suggestedLatency
975 = (device_info ? device_info->defaultHighOutputLatency : -1);
977 output_parameters.hostApiSpecificStreamInfo =
nullptr;
997 channels = y.
rows ();
1003 reset_end_sample ();
1009 octave_callback_function = fcn;
1011 reset_end_sample ();
1015 audioplayer::get_y (
void)
1021 audioplayer::get_left (
void)
const
1027 audioplayer::get_right (
void)
const
1029 return channels == 1 ?
left : right;
1033 audioplayer::set_fs (
int fs_arg)
1039 audioplayer::get_fs (
void)
1045 audioplayer::set_nbits (
int nbits_arg)
1051 audioplayer::get_nbits (
void)
1057 audioplayer::set_id (
int id_arg)
1063 audioplayer::get_id (
void)
1069 audioplayer::get_channels (
void)
1075 audioplayer::get_type (
void)
1081 audioplayer::set_sample_number (
unsigned int sample_number_arg)
1083 sample_number = sample_number_arg;
1087 audioplayer::get_sample_number (
void)
1089 return sample_number;
1093 audioplayer::get_total_samples (
void)
1095 return left.numel ();
1099 audioplayer::set_end_sample (
unsigned int end_sample_arg)
1101 end_sample = end_sample_arg;
1105 audioplayer::get_end_sample (
void)
1111 audioplayer::reset_end_sample (
void)
1113 set_end_sample (
left.numel ());
1117 audioplayer::set_tag (
const charMatrix& tag_arg)
1123 audioplayer::get_tag (
void)
1129 audioplayer::set_userdata (
const octave_value& userdata_arg)
1131 userdata = userdata_arg;
1135 audioplayer::get_userdata (
void)
1141 audioplayer::playblocking (
void)
1146 const unsigned int buffer_size = get_fs () / 20;
1150 err = Pa_OpenStream (&
stream,
nullptr, &(output_parameters), get_fs (),
1151 buffer_size, paClipOff,
nullptr,
nullptr);
1152 if (err != paNoError)
1153 error (
"audioplayer: unable to open audio playback stream");
1155 err = Pa_StartStream (
stream);
1156 if (err != paNoError)
1157 error (
"audioplayer: unable to start audio playback stream");
1159 unsigned int start, end;
1160 start = get_sample_number ();
1161 end = get_end_sample ();
1165 for (
unsigned int i = start; i < end; i += buffer_size)
1169 if (octave_callback_function !=
nullptr)
1170 octave_play_callback (
nullptr, buffer, buffer_size,
nullptr, 0,
this);
1172 portaudio_play_callback (
nullptr, buffer, buffer_size,
nullptr, 0,
this);
1174 err = Pa_WriteStream (
stream, buffer, buffer_size);
1179 audioplayer::play (
void)
1184 const unsigned int buffer_size = get_fs () / 20;
1187 if (octave_callback_function !=
nullptr)
1188 err = Pa_OpenStream (&
stream,
nullptr, &(output_parameters),
1189 get_fs (), buffer_size, paClipOff,
1190 octave_play_callback,
this);
1192 err = Pa_OpenStream (&
stream,
nullptr, &(output_parameters),
1193 get_fs (), buffer_size, paClipOff,
1194 portaudio_play_callback,
this);
1196 if (err != paNoError)
1197 error (
"audioplayer: failed to open audio playback stream");
1199 err = Pa_StartStream (
stream);
1200 if (err != paNoError)
1201 error (
"audioplayer: failed to start audio playback stream");
1205 audioplayer::pause (
void)
1207 if (get_stream () ==
nullptr)
1211 err = Pa_StopStream (
stream);
1212 if (err != paNoError)
1213 error (
"audioplayer: failed to stop audio playback stream");
1217 audioplayer::resume (
void)
1219 if (get_stream () ==
nullptr)
1223 err = Pa_StartStream (
stream);
1224 if (err != paNoError)
1225 error (
"audioplayer: failed to start audio playback stream");
1229 audioplayer::get_stream (
void)
1235 audioplayer::stop (
void)
1237 if (get_stream () ==
nullptr)
1241 set_sample_number (0);
1242 reset_end_sample ();
1243 if (! Pa_IsStreamStopped (get_stream ()))
1245 err = Pa_AbortStream (get_stream ());
1246 if (err != paNoError)
1247 error (
"audioplayer: failed to stop audio playback stream");
1250 err = Pa_CloseStream (get_stream ());
1251 if (err != paNoError)
1252 error (
"audioplayer: failed to close audio playback stream");
1258 audioplayer::isplaying (
void)
1260 if (get_stream () ==
nullptr)
1264 err = Pa_IsStreamActive (
stream);
1265 if (err != 0 && err != 1)
1266 error (
"audioplayer: checking stream activity status failed");
1274 audiorecorder (
void);
1275 ~audiorecorder (
void);
1278 double player_value (
void)
const {
return 0; }
1279 virtual double scalar_value (
bool =
false)
const {
return 0; }
1280 void print (std::ostream& os,
bool pr_as_read_syntax =
false);
1281 void print_raw (std::ostream& os,
bool pr_as_read_syntax)
const;
1285 bool is_defined (
void)
const {
return true; }
1289 void set_fs (
int fs);
1291 void set_nbits (
int nbits);
1292 int get_nbits (
void);
1293 PaSampleFormat get_sampleFormat (
void);
1294 void set_id (
int id);
1296 void set_channels (
int channels);
1297 int get_channels (
void);
1298 audio_type get_type (
void);
1300 void set_sample_number (
unsigned int sample);
1301 unsigned int get_sample_number (
void);
1302 unsigned int get_total_samples (
void);
1303 void set_end_sample (
unsigned int sample);
1304 unsigned int get_end_sample (
void);
1305 void reset_end_sample (
void);
1310 PaStream * get_stream (
void);
1313 audioplayer * getplayer (
void);
1314 bool isrecording (
void);
1315 audioplayer play (
void);
1317 void recordblocking (
float seconds);
1321 void append (
float sample_l,
float sample_r);
1330 unsigned int sample_number;
1331 unsigned int end_sample;
1335 std::vector<float>
left;
1336 std::vector<float> right;
1338 PaStreamParameters input_parameters;
1347 octave_record_callback (
const void *
input,
void *,
unsigned long frames,
1348 const PaStreamCallbackTimeInfo *,
1349 PaStreamCallbackFlags,
void *data)
1351 audiorecorder *recorder =
static_cast<audiorecorder *
> (data);
1354 error (
"audiorecorder callback function called without recorder");
1356 int channels = recorder->get_channels ();
1358 Matrix sound (frames, 2);
1359 sound.
resize (frames, 2);
1361 if (recorder->get_sampleFormat () == bits_to_format (8))
1363 static double scale_factor =
std::pow (2.0, 7) - 1.0;
1365 const int8_t *input8 =
static_cast<const int8_t *
> (
input);
1367 for (
unsigned long i = 0; i < frames; i++)
1369 float sample_l = input8[i*channels] / scale_factor;
1370 float sample_r = input8[i*channels + (channels - 1)] / scale_factor;
1372 sound(i, 0) = sample_l;
1373 sound(i, 1) = sample_r;
1379 else if (recorder->get_sampleFormat () == bits_to_format (16)
1380 && recorder->get_nbits () == 8)
1382 static double scale_factor =
std::pow (2.0, 7) - 1.0;
1384 const int16_t *input16 =
static_cast<const int16_t *
> (
input);
1386 for (
unsigned long i = 0; i < frames; i++)
1388 float sample_l = (input16[i*channels] >> 8) / scale_factor;
1389 float sample_r = (input16[i*channels + (channels - 1)] >> 8)
1392 sound(i, 0) = sample_l;
1393 sound(i, 1) = sample_r;
1396 else if (recorder->get_sampleFormat () == bits_to_format (16))
1398 static double scale_factor =
std::pow (2.0, 15) - 1.0;
1400 const int16_t *input16 =
static_cast<const int16_t *
> (
input);
1402 for (
unsigned long i = 0; i < frames; i++)
1404 float sample_l = input16[i*channels] / scale_factor;
1405 float sample_r = input16[i*channels + (channels - 1)] / scale_factor;
1407 sound(i, 0) = sample_l;
1408 sound(i, 1) = sample_r;
1411 else if (recorder->get_sampleFormat () == bits_to_format (24))
1413 static double scale_factor =
std::pow (2.0, 23);
1417 const uint8_t *input24 =
static_cast<const uint8_t *
> (
input);
1419 int32_t sample_l32, sample_r32;
1421 uint8_t *sample_l =
reinterpret_cast<uint8_t *
> (&sample_l32);
1422 uint8_t *sample_r =
reinterpret_cast<uint8_t *
> (&sample_r32);
1424 for (
unsigned long i = 0; i < frames; i++)
1426 sample_l32 = sample_r32 = 0;
1427 for (
int j = 0; j < 3; j++)
1429 sample_l[j] = input24[i*channels*3 + j];
1430 sample_r[j] = input24[i*channels*3 + (channels - 1)*3 + j];
1433 if (sample_l32 & 0x00800000)
1434 sample_l32 |= 0xff000000;
1436 if (sample_r32 & 0x00800000)
1437 sample_r32 |= 0xff000000;
1439 sound(i, 0) = sample_l32 / scale_factor;
1440 sound(i, 1) = sample_r32 / scale_factor;
1445 =
feval (recorder->octave_callback_function,
ovl (sound), 1);
1447 return retval(0).int_value ();
1451 portaudio_record_callback (
const void *
input,
void *,
unsigned long frames,
1452 const PaStreamCallbackTimeInfo *,
1453 PaStreamCallbackFlags,
void *data)
1455 audiorecorder *recorder =
static_cast<audiorecorder *
> (data);
1458 error (
"audiorecorder callback function called without recorder");
1460 int channels = recorder->get_channels ();
1462 if (recorder->get_sampleFormat () == bits_to_format (8))
1464 static float scale_factor =
std::pow (2.0f, 7) - 1.0f;
1466 const int8_t *input8 =
static_cast<const int8_t *
> (
input);
1468 for (
unsigned long i = 0; i < frames; i++)
1470 float sample_l = input8[i*channels] / scale_factor;
1471 float sample_r = input8[i*channels + (channels - 1)] / scale_factor;
1473 recorder->append (sample_l, sample_r);
1479 else if (recorder->get_sampleFormat () == bits_to_format (16)
1480 && recorder->get_nbits () == 8)
1482 static double scale_factor =
std::pow (2.0, 7) - 1.0;
1484 const int16_t *input16 =
static_cast<const int16_t *
> (
input);
1486 for (
unsigned long i = 0; i < frames; i++)
1488 float sample_l = (input16[i*channels] >> 8) / scale_factor;
1489 float sample_r = (input16[i*channels + (channels - 1)] >> 8)
1492 recorder->append (sample_l, sample_r);
1495 else if (recorder->get_sampleFormat () == bits_to_format (16))
1497 static float scale_factor =
std::pow (2.0f, 15) - 1.0f;
1499 const int16_t *input16 =
static_cast<const int16_t *
> (
input);
1501 for (
unsigned long i = 0; i < frames; i++)
1503 float sample_l = input16[i*channels] / scale_factor;
1504 float sample_r = input16[i*channels + (channels - 1)] / scale_factor;
1506 recorder->append (sample_l, sample_r);
1509 else if (recorder->get_sampleFormat () == bits_to_format (24))
1511 static float scale_factor =
std::pow (2.0f, 23);
1515 const uint8_t *input24 =
static_cast<const uint8_t *
> (
input);
1517 int32_t sample_l32, sample_r32;
1519 uint8_t *sample_l =
reinterpret_cast<uint8_t *
> (&sample_l32);
1520 uint8_t *sample_r =
reinterpret_cast<uint8_t *
> (&sample_r32);
1522 for (
unsigned long i = 0; i < frames; i++)
1524 sample_l32 = sample_r32 = 0;
1525 for (
int j = 0; j < 3; j++)
1527 sample_l[j] = input24[i*channels*3 + j];
1528 sample_r[j] = input24[i*channels*3 + (channels - 1)*3 + j];
1531 if (sample_l32 & 0x00800000)
1532 sample_l32 |= 0xff000000;
1534 if (sample_r32 & 0x00800000)
1535 sample_r32 |= 0xff000000;
1537 recorder->append (sample_l32 / scale_factor,
1538 sample_r32 / scale_factor);
1542 if (recorder->get_sample_number () >= recorder->get_end_sample ())
1548 audiorecorder::audiorecorder (
void)
1549 : octave_callback_function (nullptr),
1550 id (-1), fs (8000), nbits (8), channels (1), sample_number (0),
1551 end_sample (-1), tag (
""), y (), userdata (
Matrix ()),
1552 left (), right (),
stream (nullptr), input_parameters (), type ()
1555 audiorecorder::~audiorecorder (
void)
1560 "interrupting audiorecorder during recording");
1566 audiorecorder::print (std::ostream& os,
bool pr_as_read_syntax)
1568 print_raw (os, pr_as_read_syntax);
1573 audiorecorder::print_raw (std::ostream& os,
bool)
const
1579 audiorecorder::init (
void)
1581 if (Pa_Initialize () != paNoError)
1582 error (
"audiorecorder: initialization error");
1584 if (Pa_GetDeviceCount () < 1)
1585 error (
"audiorecorder: no audio devices found or available");
1587 int device = get_id ();
1590 device = Pa_GetDefaultInputDevice ();
1592 input_parameters.device = device;
1593 input_parameters.channelCount = get_channels ();
1594 input_parameters.sampleFormat = bits_to_format (get_nbits ());
1599 if (get_nbits () == 8)
1600 input_parameters.sampleFormat = bits_to_format (16);
1602 const PaDeviceInfo *device_info = Pa_GetDeviceInfo (device);
1606 "invalid default audio device ID = %d", device);
1608 input_parameters.suggestedLatency
1609 = (device_info ? device_info->defaultHighInputLatency : -1);
1611 input_parameters.hostApiSpecificStreamInfo =
nullptr;
1615 audiorecorder::set_fs (
int fs_arg)
1621 audiorecorder::get_fs (
void)
1627 audiorecorder::set_nbits (
int nbits_arg)
1633 audiorecorder::get_nbits (
void)
1639 audiorecorder::get_sampleFormat (
void)
1641 return input_parameters.sampleFormat;
1645 audiorecorder::set_id (
int id_arg)
1651 audiorecorder::get_id (
void)
1657 audiorecorder::set_channels (
int channels_arg)
1659 if (channels_arg != 1 && channels_arg != 2)
1660 error (
"audiorecorder: number of channels must be 1 or 2");
1662 channels = channels_arg;
1666 audiorecorder::get_channels (
void)
1672 audiorecorder::get_type (
void)
1678 audiorecorder::set_sample_number (
unsigned int sample_number_arg)
1680 sample_number = sample_number_arg;
1684 audiorecorder::get_sample_number (
void)
1686 return sample_number;
1690 audiorecorder::get_total_samples (
void)
1692 return left.size ();
1696 audiorecorder::set_end_sample (
unsigned int end_sample_arg)
1698 end_sample = end_sample_arg;
1702 audiorecorder::get_end_sample (
void)
1708 audiorecorder::reset_end_sample (
void)
1710 set_end_sample (
left.size ());
1714 audiorecorder::set_tag (
const charMatrix& tag_arg)
1720 audiorecorder::get_tag (
void)
1726 audiorecorder::set_userdata (
const octave_value& userdata_arg)
1728 userdata = userdata_arg;
1732 audiorecorder::get_userdata (
void)
1738 audiorecorder::getaudiodata (
void)
1742 unsigned int ls =
left.size ();
1745 for (
unsigned int i = 0; i < ls; i++)
1747 audio(0, i) =
left[i];
1748 audio(1, i) = right[i];
1755 audiorecorder::getplayer (
void)
1757 audioplayer *player =
new audioplayer ();
1759 player->set_y (getaudiodata ());
1760 player->set_fs (get_fs ());
1761 player->set_nbits (get_nbits ());
1768 audiorecorder::isrecording (
void)
1770 if (get_stream () ==
nullptr)
1774 err = Pa_IsStreamActive (
stream);
1775 if (err != 0 && err != 1)
1776 error (
"audiorecorder: checking stream activity status failed");
1782 audiorecorder::record (
void)
1790 const unsigned int buffer_size = get_fs () / 20;
1793 if (octave_callback_function !=
nullptr)
1795 err = Pa_OpenStream (&
stream, &(input_parameters),
nullptr,
1796 get_fs (), buffer_size, paClipOff,
1797 octave_record_callback,
this);
1801 err = Pa_OpenStream (&
stream, &(input_parameters),
nullptr,
1802 get_fs (), buffer_size, paClipOff,
1803 portaudio_record_callback,
this);
1805 if (err != paNoError)
1806 error (
"audiorecorder: unable to open audio recording stream");
1808 err = Pa_StartStream (
stream);
1809 if (err != paNoError)
1810 error (
"audiorecorder: unable to start audio recording stream");
1814 audiorecorder::recordblocking (
float seconds)
1822 const unsigned int buffer_size = get_fs () / 20;
1826 err = Pa_OpenStream (&
stream, &(input_parameters),
nullptr,
1827 get_fs (), buffer_size, paClipOff,
nullptr,
this);
1828 if (err != paNoError)
1829 error (
"audiorecorder: unable to open audio recording stream");
1831 err = Pa_StartStream (
stream);
1832 if (err != paNoError)
1833 error (
"audiorecorder: unable to start audio recording stream");
1835 unsigned int frames = seconds * get_fs ();
1839 for (
unsigned int i = 0; i < frames; i += buffer_size)
1843 Pa_ReadStream (get_stream (), buffer, buffer_size);
1845 if (octave_callback_function !=
nullptr)
1846 octave_record_callback (buffer,
nullptr, buffer_size,
nullptr, 0,
this);
1848 portaudio_record_callback (buffer,
nullptr, buffer_size,
nullptr, 0,
this);
1853 audiorecorder::pause (
void)
1855 if (get_stream () ==
nullptr)
1859 err = Pa_StopStream (
stream);
1860 if (err != paNoError)
1861 error (
"audiorecorder: unable to stop audio recording stream");
1865 audiorecorder::resume (
void)
1867 if (get_stream () ==
nullptr)
1871 err = Pa_StartStream (
stream);
1872 if (err != paNoError)
1873 error (
"audiorecorder: unable to start audio recording stream");
1877 audiorecorder::stop (
void)
1879 if (get_stream () ==
nullptr)
1883 if (! Pa_IsStreamStopped (get_stream ()))
1885 err = Pa_AbortStream (get_stream ());
1886 if (err != paNoError)
1887 error (
"audioplayer: unable to stop audio playback stream");
1890 err = Pa_CloseStream (
stream);
1891 if (err != paNoError)
1892 error (
"audiorecorder: unable to close audio recording stream");
1894 set_sample_number (0);
1895 reset_end_sample ();
1900 audiorecorder::append (
float sample_l,
float sample_r)
1902 left.push_back (sample_l);
1903 right.push_back (sample_r);
1904 set_sample_number (get_sample_number () + 1);
1908 audiorecorder::get_stream (
void)
1915 DEFUN_DLD (__recorder_audiorecorder__, args, ,
1925 #if defined (HAVE_PORTAUDIO)
1927 int nargin = args.
length ();
1929 audiorecorder *recorder =
new audiorecorder ();
1933 bool is_function = (args(0).is_string () || args(0).is_function_handle ()
1934 || args(0).is_inline_function ());
1937 error (
"audiorecorder: callback functions are not yet implemented");
1942 recorder->set_fs (args(0).int_value ());
1943 recorder->set_nbits (args(1).int_value ());
1944 recorder->set_channels (args(2).int_value ());
1949 recorder->set_id (args(3).int_value ());
1956 octave_unused_parameter (args);
1959 "audio playback and recording through PortAudio");
1965 #if defined (HAVE_PORTAUDIO)
1967 static audiorecorder *
1974 audiorecorder *rec =
dynamic_cast<audiorecorder *
> (ncrep);
1976 error (
"audiodevinfo.cc (get_recorder): dynamic_cast to audiorecorder failed");
1983 DEFUN_DLD (__recorder_getaudiodata__, args, ,
1991 #if defined (HAVE_PORTAUDIO)
1992 retval = get_recorder (args(0))->getaudiodata ();
1994 octave_unused_parameter (args);
1997 "audio playback and recording through PortAudio");
2003 DEFUN_DLD (__recorder_get_channels__, args, ,
2011 #if defined (HAVE_PORTAUDIO)
2012 retval = get_recorder (args(0))->get_channels ();
2014 octave_unused_parameter (args);
2017 "audio playback and recording through PortAudio");
2031 #if defined (HAVE_PORTAUDIO)
2032 retval = get_recorder (args(0))->get_fs ();
2034 octave_unused_parameter (args);
2037 "audio playback and recording through PortAudio");
2051 #if defined (HAVE_PORTAUDIO)
2052 retval = get_recorder (args(0))->get_id ();
2054 octave_unused_parameter (args);
2057 "audio playback and recording through PortAudio");
2063 DEFUN_DLD (__recorder_get_nbits__, args, ,
2071 #if defined (HAVE_PORTAUDIO)
2072 retval = get_recorder (args(0))->get_nbits ();
2074 octave_unused_parameter (args);
2077 "audio playback and recording through PortAudio");
2083 DEFUN_DLD (__recorder_get_sample_number__, args, ,
2091 #if defined (HAVE_PORTAUDIO)
2092 retval = get_recorder (args(0))->get_sample_number ();
2094 octave_unused_parameter (args);
2097 "audio playback and recording through PortAudio");
2103 DEFUN_DLD (__recorder_get_tag__, args, ,
2111 #if defined (HAVE_PORTAUDIO)
2112 retval = get_recorder (args(0))->get_tag ();
2114 octave_unused_parameter (args);
2117 "audio playback and recording through PortAudio");
2123 DEFUN_DLD (__recorder_get_total_samples__, args, ,
2131 #if defined (HAVE_PORTAUDIO)
2132 retval = get_recorder (args(0))->get_total_samples ();
2134 octave_unused_parameter (args);
2137 "audio playback and recording through PortAudio");
2143 DEFUN_DLD (__recorder_get_userdata__, args, ,
2151 #if defined (HAVE_PORTAUDIO)
2152 retval = get_recorder (args(0))->get_userdata ();
2154 octave_unused_parameter (args);
2157 "audio playback and recording through PortAudio");
2163 DEFUN_DLD (__recorder_isrecording__, args, ,
2171 #if defined (HAVE_PORTAUDIO)
2172 retval = get_recorder (args(0))->isrecording ();
2174 octave_unused_parameter (args);
2177 "audio playback and recording through PortAudio");
2189 #if defined (HAVE_PORTAUDIO)
2190 get_recorder (args(0))->pause ();
2193 octave_unused_parameter (args);
2196 "audio playback and recording through PortAudio");
2200 DEFUN_DLD (__recorder_recordblocking__, args, ,
2206 #if defined (HAVE_PORTAUDIO)
2207 float seconds = args(1).float_value ();
2208 get_recorder (args(0))->recordblocking (seconds);
2211 octave_unused_parameter (args);
2214 "audio playback and recording through PortAudio");
2225 #if defined (HAVE_PORTAUDIO)
2226 audiorecorder *recorder = get_recorder (args(0));
2228 if (args.length () == 2)
2229 recorder->set_end_sample (args(1).int_value () * recorder->get_fs ());
2231 recorder->record ();
2234 octave_unused_parameter (args);
2237 "audio playback and recording through PortAudio");
2247 #if defined (HAVE_PORTAUDIO)
2248 if (args.length () == 1)
2249 get_recorder (args(0))->resume ();
2252 octave_unused_parameter (args);
2255 "audio playback and recording through PortAudio");
2265 #if defined (HAVE_PORTAUDIO)
2266 if (args.length () == 2)
2267 get_recorder (args(0))->set_fs (args(1).int_value ());
2270 octave_unused_parameter (args);
2273 "audio playback and recording through PortAudio");
2277 DEFUN_DLD (__recorder_set_tag__, args, ,
2283 #if defined (HAVE_PORTAUDIO)
2284 if (args.length () == 2)
2285 get_recorder (args(0))->set_tag (args(1).char_matrix_value ());
2288 octave_unused_parameter (args);
2291 "audio playback and recording through PortAudio");
2295 DEFUN_DLD (__recorder_set_userdata__, args, ,
2301 #if defined (HAVE_PORTAUDIO)
2302 if (args.length () == 2)
2303 get_recorder (args(0))->set_userdata (args(1));
2306 octave_unused_parameter (args);
2309 "audio playback and recording through PortAudio");
2319 #if defined (HAVE_PORTAUDIO)
2320 if (args.length () == 1)
2321 get_recorder (args(0))->stop ();
2324 octave_unused_parameter (args);
2327 "audio playback and recording through PortAudio");
2331 DEFUN_DLD (__player_audioplayer__, args, ,
2341 #if defined (HAVE_PORTAUDIO)
2343 audioplayer *recorder =
new audioplayer ();
2345 bool is_function = (args(0).is_string () || args(0).is_function_handle ()
2346 || args(0).is_inline_function ());
2349 error (
"audioplayer: callback functions are not yet implemented");
2351 recorder->set_y (args(0));
2352 recorder->set_fs (args(1).int_value ());
2354 if (args.length () > 2)
2357 int nbits = args(2).int_value ();
2358 if (nbits != 8 && nbits != 16 && nbits != 24)
2359 error (
"audioplayer: NBITS must be 8, 16, or 24");
2361 switch (args.length ())
2364 recorder->set_nbits (nbits);
2368 recorder->set_nbits (nbits);
2369 recorder->set_id (args(3).int_value ());
2375 recorder->init_fn ();
2381 octave_unused_parameter (args);
2384 "audio playback and recording through PortAudio");
2390 #if defined (HAVE_PORTAUDIO)
2392 static audioplayer *
2399 audioplayer *pl =
dynamic_cast<audioplayer *
> (ncrep);
2401 error (
"audiodevinfo.cc (get_player): dynamic_cast to audioplayer failed");
2408 DEFUN_DLD (__player_get_channels__, args, ,
2416 #if defined (HAVE_PORTAUDIO)
2417 if (args.length () == 1)
2418 retval = get_player (args(0))->get_channels ();
2420 octave_unused_parameter (args);
2423 "audio playback and recording through PortAudio");
2437 #if defined (HAVE_PORTAUDIO)
2438 if (args.length () == 1)
2439 retval = get_player (args(0))->get_fs ();
2441 octave_unused_parameter (args);
2444 "audio playback and recording through PortAudio");
2458 #if defined (HAVE_PORTAUDIO)
2459 if (args.length () == 1)
2460 retval = get_player (args(0))->get_id ();
2462 octave_unused_parameter (args);
2465 "audio playback and recording through PortAudio");
2471 DEFUN_DLD (__player_get_nbits__, args, ,
2479 #if defined (HAVE_PORTAUDIO)
2480 if (args.length () == 1)
2481 retval = get_player (args(0))->get_nbits ();
2483 octave_unused_parameter (args);
2486 "audio playback and recording through PortAudio");
2492 DEFUN_DLD (__player_get_sample_number__, args, ,
2500 #if defined (HAVE_PORTAUDIO)
2501 if (args.length () == 1)
2502 retval = get_player (args(0))->get_sample_number ();
2504 octave_unused_parameter (args);
2507 "audio playback and recording through PortAudio");
2521 #if defined (HAVE_PORTAUDIO)
2522 if (args.length () == 1)
2523 retval = get_player (args(0))->get_tag ();
2525 octave_unused_parameter (args);
2528 "audio playback and recording through PortAudio");
2534 DEFUN_DLD (__player_get_total_samples__, args, ,
2542 #if defined (HAVE_PORTAUDIO)
2543 if (args.length () == 1)
2544 retval = get_player (args(0))->get_total_samples ();
2546 octave_unused_parameter (args);
2549 "audio playback and recording through PortAudio");
2555 DEFUN_DLD (__player_get_userdata__, args, ,
2563 #if defined (HAVE_PORTAUDIO)
2564 if (args.length () == 1)
2565 retval = get_player (args(0))->get_userdata ();
2567 octave_unused_parameter (args);
2570 "audio playback and recording through PortAudio");
2576 DEFUN_DLD (__player_isplaying__, args, ,
2584 #if defined (HAVE_PORTAUDIO)
2585 if (args.length () == 1)
2586 retval = get_player (args(0))->isplaying ();
2588 octave_unused_parameter (args);
2591 "audio playback and recording through PortAudio");
2603 #if defined (HAVE_PORTAUDIO)
2604 if (args.length () == 1)
2605 get_player (args(0))->pause ();
2608 octave_unused_parameter (args);
2611 "audio playback and recording through PortAudio");
2615 DEFUN_DLD (__player_playblocking__, args, ,
2623 #if defined (HAVE_PORTAUDIO)
2625 audioplayer *player = get_player (args(0));
2627 if (args.length () == 1)
2629 player->playblocking ();
2631 else if (args.length () == 2)
2633 if (args(1).is_matrix_type ())
2637 unsigned int start =
range.elem (0) - 1;
2638 unsigned int end =
range.elem (1) - 1;
2640 if (start > player->get_total_samples ()
2641 || start > end || end > player->get_total_samples ())
2642 error (
"audioplayer: invalid range specified for playback");
2644 player->set_sample_number (start);
2645 player->set_end_sample (end);
2649 unsigned int start = args(1).int_value () - 1;
2651 if (start > player->get_total_samples ())
2652 error (
"audioplayer: invalid range specified for playback");
2654 player->set_sample_number (start);
2657 player->playblocking ();
2662 octave_unused_parameter (args);
2665 "audio playback and recording through PortAudio");
2677 #if defined (HAVE_PORTAUDIO)
2679 if (args.length () == 1)
2681 get_player (args(0))->play ();
2683 else if (args.length () == 2)
2685 audioplayer *player = get_player (args(0));
2687 if (args(1).is_matrix_type ())
2691 unsigned int start =
range.elem (0) - 1;
2692 unsigned int end =
range.elem (1) - 1;
2694 if (start > player->get_total_samples ()
2695 || start > end || end > player->get_total_samples ())
2696 error (
"audioplayer: invalid range specified for playback");
2698 player->set_sample_number (start);
2699 player->set_end_sample (end);
2703 unsigned int start = args(1).int_value () - 1;
2705 if (start > player->get_total_samples ())
2706 error (
"audioplayer: invalid range specified for playback");
2708 player->set_sample_number (start);
2716 octave_unused_parameter (args);
2719 "audio playback and recording through PortAudio");
2729 #if defined (HAVE_PORTAUDIO)
2730 if (args.length () == 1)
2731 get_player (args(0))->resume ();
2734 octave_unused_parameter (args);
2737 "audio playback and recording through PortAudio");
2747 #if defined (HAVE_PORTAUDIO)
2748 if (args.length () == 2)
2749 get_player (args(0))->set_fs (args(1).int_value ());
2752 octave_unused_parameter (args);
2755 "audio playback and recording through PortAudio");
2765 #if defined (HAVE_PORTAUDIO)
2766 if (args.length () == 2)
2767 get_player (args(0))->set_tag (args(1).char_matrix_value ());
2770 octave_unused_parameter (args);
2773 "audio playback and recording through PortAudio");
2777 DEFUN_DLD (__player_set_userdata__, args, ,
2783 #if defined (HAVE_PORTAUDIO)
2784 if (args.length () == 2)
2785 get_player (args(0))->set_userdata (args(1));
2788 octave_unused_parameter (args);
2791 "audio playback and recording through PortAudio");
2801 #if defined (HAVE_PORTAUDIO)
2802 if (args.length () == 1)
2803 get_player (args(0))->stop ();
2806 octave_unused_parameter (args);
2809 "audio playback and recording through PortAudio");
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type columns(void) const
OCTARRAY_OVERRIDABLE_FUNC_API const T * data(void) const
Size of the specified dimension.
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type rows(void) const
Matrix transpose(void) const
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
OCTAVE_API ColumnVector column(octave_idx_type i) const
Vector representing the dimensions (size) of an Array.
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)
octave_idx_type length(void) const
const octave_base_value & get_rep(void) const
int int_value(bool req_int=false, bool frc_str_conv=false) 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
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define DEFUN_DLD(name, args_name, nargout_name, doc)
Macro to define an at run time dynamically loadable builtin function.
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_int< T > pow(const octave_int< T > &a, const octave_int< T > &b)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
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.
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_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
std::size_t format(std::ostream &os, const char *fmt,...)