Mercurial > octave-nkf
comparison libinterp/dldfcn/audiodevinfo.cc @ 19547:4cb4210bd392
use C++ style casts in audio code
* audiodevinfo.cc, audioread.cc: Use C++ style casts.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 02 Jan 2015 02:04:40 -0500 |
parents | a5eb03a7e2a5 |
children | ef6875adb053 |
comparison
equal
deleted
inserted
replaced
19546:a5eb03a7e2a5 | 19547:4cb4210bd392 |
---|---|
521 static int | 521 static int |
522 octave_play_callback (const void *, void *output, unsigned long frames, | 522 octave_play_callback (const void *, void *output, unsigned long frames, |
523 const PaStreamCallbackTimeInfo *, | 523 const PaStreamCallbackTimeInfo *, |
524 PaStreamCallbackFlags, void *data) | 524 PaStreamCallbackFlags, void *data) |
525 { | 525 { |
526 audioplayer *player = (audioplayer *)data; | 526 audioplayer *player = static_cast<audioplayer *> (data); |
527 int big_endian = is_big_endian (); | 527 int big_endian = is_big_endian (); |
528 octave_value_list args, retval; | 528 octave_value_list args, retval; |
529 args(0) = frames; | 529 args(0) = frames; |
530 retval = feval (player->octave_callback_function, args, 1); | 530 retval = feval (player->octave_callback_function, args, 1); |
531 RowVector sound_l, sound_r; | 531 RowVector sound_l, sound_r; |
554 | 554 |
555 for (int i = 0; i < frames; i++) | 555 for (int i = 0; i < frames; i++) |
556 { | 556 { |
557 if (player->get_nbits () == 8) | 557 if (player->get_nbits () == 8) |
558 { | 558 { |
559 int8_t *buffer = (int8_t *)output; | 559 int8_t *buffer = static_cast<int8_t *> (output); |
560 buffer[2 * i] = sound_l.elem (i) * (pow (2.0, 7) - 1); | 560 buffer[2 * i] = sound_l.elem (i) * (pow (2.0, 7) - 1); |
561 buffer[2 * i + 1] = sound_r.elem (i) * (pow (2.0, 7) - 1); | 561 buffer[2 * i + 1] = sound_r.elem (i) * (pow (2.0, 7) - 1); |
562 } | 562 } |
563 else if (player->get_nbits () == 16) | 563 else if (player->get_nbits () == 16) |
564 { | 564 { |
565 int16_t *buffer = (int16_t *)output; | 565 int16_t *buffer = static_cast<int16_t *> (output); |
566 buffer[2 * i] = sound_l.elem (i) * (pow (2.0, 15) - 1); | 566 buffer[2 * i] = sound_l.elem (i) * (pow (2.0, 15) - 1); |
567 buffer[2 * i + 1] = sound_r.elem (i) * (pow (2.0, 15) - 1); | 567 buffer[2 * i + 1] = sound_r.elem (i) * (pow (2.0, 15) - 1); |
568 } | 568 } |
569 else if (player->get_nbits () == 24) | 569 else if (player->get_nbits () == 24) |
570 { | 570 { |
571 uint8_t *buffer = (uint8_t *)output; | 571 uint8_t *buffer = static_cast<uint8_t *> (output); |
572 int32_t sample_l = sound_l.elem (i) * (pow (2.0, 23) - 1); | 572 int32_t sample_l = sound_l.elem (i) * (pow (2.0, 23) - 1); |
573 int32_t sample_r = sound_r.elem (i) * (pow (2.0, 23) - 1); | 573 int32_t sample_r = sound_r.elem (i) * (pow (2.0, 23) - 1); |
574 sample_l &= 0x00ffffff; | 574 sample_l &= 0x00ffffff; |
575 sample_r &= 0x00ffffff; | 575 sample_r &= 0x00ffffff; |
576 uint8_t *_sample_l = (uint8_t *)&sample_l; | 576 // FIXME: Would a mask work better? |
577 uint8_t *_sample_r = (uint8_t *)&sample_r; | 577 uint8_t *_sample_l = reinterpret_cast<uint8_t *> (&sample_l); |
578 uint8_t *_sample_r = reinterpret_cast<uint8_t *> (&sample_r); | |
578 buffer[i * 6 + 0] = _sample_l[0 + big_endian]; | 579 buffer[i * 6 + 0] = _sample_l[0 + big_endian]; |
579 buffer[i * 6 + 1] = _sample_l[1 + big_endian]; | 580 buffer[i * 6 + 1] = _sample_l[1 + big_endian]; |
580 buffer[i * 6 + 2] = _sample_l[2 + big_endian]; | 581 buffer[i * 6 + 2] = _sample_l[2 + big_endian]; |
581 buffer[i * 6 + 3] = _sample_r[0 + big_endian]; | 582 buffer[i * 6 + 3] = _sample_r[0 + big_endian]; |
582 buffer[i * 6 + 4] = _sample_r[1 + big_endian]; | 583 buffer[i * 6 + 4] = _sample_r[1 + big_endian]; |
589 static int | 590 static int |
590 portaudio_play_callback (const void *, void *output, unsigned long frames, | 591 portaudio_play_callback (const void *, void *output, unsigned long frames, |
591 const PaStreamCallbackTimeInfo*, | 592 const PaStreamCallbackTimeInfo*, |
592 PaStreamCallbackFlags, void *data) | 593 PaStreamCallbackFlags, void *data) |
593 { | 594 { |
594 audioplayer *player = (audioplayer *)data; | 595 audioplayer *player = static_cast<audioplayer *> (data); |
595 int big_endian = is_big_endian (); | 596 int big_endian = is_big_endian (); |
596 int channels = player->get_channels (); | 597 int channels = player->get_channels (); |
597 RowVector *sound_l = player->get_left (); | 598 RowVector *sound_l = player->get_left (); |
598 RowVector *sound_r; | 599 RowVector *sound_r; |
599 | 600 |
610 | 611 |
611 if (player->get_type () == DOUBLE) | 612 if (player->get_type () == DOUBLE) |
612 { | 613 { |
613 if (player->get_nbits () == 8) | 614 if (player->get_nbits () == 8) |
614 { | 615 { |
615 int8_t *buffer = (int8_t *)output; | 616 int8_t *buffer = static_cast<int8_t *> (output); |
616 buffer[k] = sound_l->elem (sample_number) * (pow (2.0, 7) - 1); | 617 buffer[k] = sound_l->elem (sample_number) * (pow (2.0, 7) - 1); |
617 buffer[k + 1] = sound_r->elem (sample_number) * (pow (2.0, 7) - 1); | 618 buffer[k + 1] = sound_r->elem (sample_number) * (pow (2.0, 7) - 1); |
618 } | 619 } |
619 else if (player->get_nbits () == 16) | 620 else if (player->get_nbits () == 16) |
620 { | 621 { |
621 int16_t *buffer = (int16_t *)output; | 622 int16_t *buffer = static_cast<int16_t *> (output); |
622 buffer[k] = sound_l->elem (sample_number) * (pow (2.0, 15) - 1); | 623 buffer[k] = sound_l->elem (sample_number) * (pow (2.0, 15) - 1); |
623 buffer[k + 1] = sound_r->elem (sample_number) * (pow (2.0, 15) - 1); | 624 buffer[k + 1] = sound_r->elem (sample_number) * (pow (2.0, 15) - 1); |
624 } | 625 } |
625 else if (player->get_nbits () == 24) | 626 else if (player->get_nbits () == 24) |
626 { | 627 { |
627 uint8_t *buffer = (uint8_t *)output; | 628 uint8_t *buffer = static_cast<uint8_t *> (output); |
628 int32_t sample_l = sound_l->elem (sample_number) * (pow (2.0, 23) - 1); | 629 int32_t sample_l = sound_l->elem (sample_number) * (pow (2.0, 23) - 1); |
629 int32_t sample_r = sound_r->elem (sample_number) * (pow (2.0, 23) - 1); | 630 int32_t sample_r = sound_r->elem (sample_number) * (pow (2.0, 23) - 1); |
630 sample_l &= 0x00ffffff; | 631 sample_l &= 0x00ffffff; |
631 sample_r &= 0x00ffffff; | 632 sample_r &= 0x00ffffff; |
632 uint8_t *_sample_l = (uint8_t *)&sample_l; | 633 // FIXME: Would a mask work better? |
633 uint8_t *_sample_r = (uint8_t *)&sample_r; | 634 uint8_t *_sample_l = reinterpret_cast<uint8_t *> (&sample_l); |
635 uint8_t *_sample_r = reinterpret_cast<uint8_t *> (&sample_r); | |
634 buffer[j * 6 + 0] = _sample_l[0 + big_endian]; | 636 buffer[j * 6 + 0] = _sample_l[0 + big_endian]; |
635 buffer[j * 6 + 1] = _sample_l[1 + big_endian]; | 637 buffer[j * 6 + 1] = _sample_l[1 + big_endian]; |
636 buffer[j * 6 + 2] = _sample_l[2 + big_endian]; | 638 buffer[j * 6 + 2] = _sample_l[2 + big_endian]; |
637 buffer[j * 6 + 3] = _sample_r[0 + big_endian]; | 639 buffer[j * 6 + 3] = _sample_r[0 + big_endian]; |
638 buffer[j * 6 + 4] = _sample_r[1 + big_endian]; | 640 buffer[j * 6 + 4] = _sample_r[1 + big_endian]; |
639 buffer[j * 6 + 5] = _sample_r[2 + big_endian]; | 641 buffer[j * 6 + 5] = _sample_r[2 + big_endian]; |
640 } | 642 } |
641 } | 643 } |
642 else if (player->get_type () == INT8) | 644 else if (player->get_type () == INT8) |
643 { | 645 { |
644 int8_t *buffer = (int8_t *)output; | 646 int8_t *buffer = static_cast<int8_t *> (output); |
645 buffer[k] = sound_l->elem (sample_number); | 647 buffer[k] = sound_l->elem (sample_number); |
646 buffer[k + 1] = sound_r->elem (sample_number); | 648 buffer[k + 1] = sound_r->elem (sample_number); |
647 } | 649 } |
648 else if (player->get_type () == UINT8) | 650 else if (player->get_type () == UINT8) |
649 { | 651 { |
650 uint8_t *buffer = (uint8_t *)output; | 652 uint8_t *buffer = static_cast<uint8_t *> (output); |
651 buffer[k] = sound_l->elem (sample_number); | 653 buffer[k] = sound_l->elem (sample_number); |
652 buffer[k + 1] = sound_r->elem (sample_number); | 654 buffer[k + 1] = sound_r->elem (sample_number); |
653 } | 655 } |
654 else if (player->get_type () == INT16) | 656 else if (player->get_type () == INT16) |
655 { | 657 { |
656 int16_t *buffer = (int16_t *)output; | 658 int16_t *buffer = static_cast<int16_t *> (output); |
657 buffer[k] = sound_l->elem (sample_number); | 659 buffer[k] = sound_l->elem (sample_number); |
658 buffer[k + 1] = sound_r->elem (sample_number); | 660 buffer[k + 1] = sound_r->elem (sample_number); |
659 } | 661 } |
660 player->set_sample_number (sample_number + 1); | 662 player->set_sample_number (sample_number + 1); |
661 } | 663 } |
951 start = this->get_sample_number (); | 953 start = this->get_sample_number (); |
952 end = this->get_end_sample (); | 954 end = this->get_end_sample (); |
953 for (int i = start; i < end; i += BUFFER_SIZE) | 955 for (int i = start; i < end; i += BUFFER_SIZE) |
954 { | 956 { |
955 if (this->octave_callback_function != 0) | 957 if (this->octave_callback_function != 0) |
956 octave_play_callback (0, (void *)buffer, BUFFER_SIZE, 0, 0, (void *)this); | 958 octave_play_callback (0, buffer, BUFFER_SIZE, 0, 0, this); |
957 else | 959 else |
958 portaudio_play_callback (0, (void *)buffer, BUFFER_SIZE, 0, 0, (void *)this); | 960 portaudio_play_callback (0, buffer, BUFFER_SIZE, 0, 0, this); |
961 | |
959 err = Pa_WriteStream (stream, buffer, BUFFER_SIZE); | 962 err = Pa_WriteStream (stream, buffer, BUFFER_SIZE); |
960 } | 963 } |
961 | 964 |
962 err = Pa_StopStream (stream); | 965 err = Pa_StopStream (stream); |
963 if (err != paNoError) | 966 if (err != paNoError) |
984 if (this->get_stream ()) | 987 if (this->get_stream ()) |
985 this->stop (); | 988 this->stop (); |
986 | 989 |
987 PaError err; | 990 PaError err; |
988 if (this->octave_callback_function != 0) | 991 if (this->octave_callback_function != 0) |
989 err = Pa_OpenStream (&stream, NULL, &(this->output_parameters), this->get_fs (), BUFFER_SIZE, paClipOff, octave_play_callback, (void *)this); | 992 err = Pa_OpenStream (&stream, NULL, &(this->output_parameters), |
993 this->get_fs (), BUFFER_SIZE, paClipOff, | |
994 octave_play_callback, this); | |
990 else | 995 else |
991 err = Pa_OpenStream (&stream, NULL, &(this->output_parameters), this->get_fs (), BUFFER_SIZE, paClipOff, portaudio_play_callback, (void *)this); | 996 err = Pa_OpenStream (&stream, NULL, &(this->output_parameters), |
997 this->get_fs (), BUFFER_SIZE, paClipOff, | |
998 portaudio_play_callback, this); | |
992 | 999 |
993 if (err != paNoError) | 1000 if (err != paNoError) |
994 { | 1001 { |
995 error ("audioplayer: Error opening audio playback stream"); | 1002 error ("audioplayer: Error opening audio playback stream"); |
996 return; | 1003 return; |
1163 static int | 1170 static int |
1164 octave_record_callback (const void *input, void *, unsigned long frames, | 1171 octave_record_callback (const void *input, void *, unsigned long frames, |
1165 const PaStreamCallbackTimeInfo *, | 1172 const PaStreamCallbackTimeInfo *, |
1166 PaStreamCallbackFlags, void *data) | 1173 PaStreamCallbackFlags, void *data) |
1167 { | 1174 { |
1168 audiorecorder *recorder = (audiorecorder *)data; | 1175 audiorecorder *recorder = static_cast<audiorecorder *> (data); |
1169 int channels = recorder->get_channels (); | 1176 int channels = recorder->get_channels (); |
1170 float sample_l, sample_r; | 1177 float sample_l, sample_r; |
1171 Matrix sound; | 1178 Matrix sound; |
1172 sound.resize (frames, 2); | 1179 sound.resize (frames, 2); |
1173 if (recorder->get_nbits () == 8) | 1180 if (recorder->get_nbits () == 8) |
1174 { | 1181 { |
1175 int8_t *input8 = (int8_t *)input; | 1182 const int8_t *input8 = static_cast<const int8_t *> (input); |
1176 for (int i = 0; i < frames; i++) | 1183 for (int i = 0; i < frames; i++) |
1177 { | 1184 { |
1178 sample_l = input8[i * channels] / (pow (2.0, 7) - 1.0); | 1185 sample_l = input8[i * channels] / (pow (2.0, 7) - 1.0); |
1179 sample_r = input8[i * channels + (channels - 1)] / (pow (2.0, 7) - 1.0); | 1186 sample_r = input8[i * channels + (channels - 1)] / (pow (2.0, 7) - 1.0); |
1180 sound(i, 0) = sample_l; | 1187 sound(i, 0) = sample_l; |
1181 sound(i, 1) = sample_r; | 1188 sound(i, 1) = sample_r; |
1182 } | 1189 } |
1183 } | 1190 } |
1184 else if (recorder->get_nbits () == 16) | 1191 else if (recorder->get_nbits () == 16) |
1185 { | 1192 { |
1186 int16_t *input16 = (int16_t *)input; | 1193 const int16_t *input16 = static_cast<const int16_t *> (input); |
1187 for (int i = 0; i < frames; i++) | 1194 for (int i = 0; i < frames; i++) |
1188 { | 1195 { |
1189 sample_l = input16[i * channels] / (pow (2.0, 15) - 1.0); | 1196 sample_l = input16[i * channels] / (pow (2.0, 15) - 1.0); |
1190 sample_r = input16[i * channels + (channels - 1)] / (pow (2.0, 15) - 1.0); | 1197 sample_r = input16[i * channels + (channels - 1)] / (pow (2.0, 15) - 1.0); |
1191 sound(i, 0) = sample_l; | 1198 sound(i, 0) = sample_l; |
1192 sound(i, 1) = sample_r; | 1199 sound(i, 1) = sample_r; |
1193 } | 1200 } |
1194 } | 1201 } |
1195 else if (recorder->get_nbits () == 24) | 1202 else if (recorder->get_nbits () == 24) |
1196 { | 1203 { |
1197 uint8_t *input24 = (uint8_t *)input; | 1204 // FIXME: Is there a better way? |
1205 const uint8_t *input24 = static_cast<const uint8_t *> (input); | |
1198 int32_t sample_l32, sample_r32; | 1206 int32_t sample_l32, sample_r32; |
1199 uint8_t *_sample_l = (uint8_t *)&sample_l; | 1207 uint8_t *_sample_l = reinterpret_cast<uint8_t *> (&sample_l); |
1200 uint8_t *_sample_r = (uint8_t *)&sample_r; | 1208 uint8_t *_sample_r = reinterpret_cast<uint8_t *> (&sample_r); |
1201 for (int i = 0; i < frames; i++) | 1209 for (int i = 0; i < frames; i++) |
1202 { | 1210 { |
1203 for (int j = 0; j < 3; j++) | 1211 for (int j = 0; j < 3; j++) |
1204 { | 1212 { |
1205 _sample_l[j] = input24[i * channels * 3 + j]; | 1213 _sample_l[j] = input24[i * channels * 3 + j]; |
1206 _sample_r[j] = input24[i * channels * 3 + (channels - 1) * 3 + j]; | 1214 _sample_r[j] = input24[i * channels * 3 + (channels - 1) * 3 + j]; |
1207 } | 1215 } |
1208 if (sample_l32 & 0x00800000) | 1216 if (sample_l32 & 0x00800000) |
1209 sample_l32 |= 0xff000000; | 1217 sample_l32 |= 0xff000000; |
1210 if (sample_r32 & 0x00800000) | 1218 if (sample_r32 & 0x00800000) |
1211 sample_r32 |= 0xff000000; | 1219 sample_r32 |= 0xff000000; |
1223 static int | 1231 static int |
1224 portaudio_record_callback (const void *input, void *, unsigned long frames, | 1232 portaudio_record_callback (const void *input, void *, unsigned long frames, |
1225 const PaStreamCallbackTimeInfo *, | 1233 const PaStreamCallbackTimeInfo *, |
1226 PaStreamCallbackFlags, void *data) | 1234 PaStreamCallbackFlags, void *data) |
1227 { | 1235 { |
1228 audiorecorder *recorder = (audiorecorder *)data; | 1236 audiorecorder *recorder = static_cast<audiorecorder *> (data); |
1229 int channels = recorder->get_channels (); | 1237 int channels = recorder->get_channels (); |
1230 float sample_l, sample_r; | 1238 float sample_l, sample_r; |
1231 if (recorder->get_nbits () == 8) | 1239 if (recorder->get_nbits () == 8) |
1232 { | 1240 { |
1233 int8_t *input8 = (int8_t *)input; | 1241 const int8_t *input8 = static_cast<const int8_t *> (input); |
1234 for (int i = 0; i < frames; i++) | 1242 for (int i = 0; i < frames; i++) |
1235 { | 1243 { |
1236 sample_l = input8[i * channels] / (pow (2.0, 7) - 1.0); | 1244 sample_l = input8[i * channels] / (pow (2.0, 7) - 1.0); |
1237 sample_r = input8[i * channels + (channels - 1)] / (pow (2.0, 7) - 1.0); | 1245 sample_r = input8[i * channels + (channels - 1)] / (pow (2.0, 7) - 1.0); |
1238 recorder->append (sample_l, sample_r); | 1246 recorder->append (sample_l, sample_r); |
1239 } | 1247 } |
1240 } | 1248 } |
1241 else if (recorder->get_nbits () == 16) | 1249 else if (recorder->get_nbits () == 16) |
1242 { | 1250 { |
1243 int16_t *input16 = (int16_t *)input; | 1251 const int16_t *input16 = static_cast<const int16_t *> (input); |
1244 for (int i = 0; i < frames; i++) | 1252 for (int i = 0; i < frames; i++) |
1245 { | 1253 { |
1246 sample_l = input16[i * channels] / (pow (2.0, 15) - 1.0); | 1254 sample_l = input16[i * channels] / (pow (2.0, 15) - 1.0); |
1247 sample_r = input16[i * channels + (channels - 1)] / (pow (2.0, 15) - 1.0); | 1255 sample_r = input16[i * channels + (channels - 1)] / (pow (2.0, 15) - 1.0); |
1248 recorder->append (sample_l, sample_r); | 1256 recorder->append (sample_l, sample_r); |
1249 } | 1257 } |
1250 } | 1258 } |
1251 else if (recorder->get_nbits () == 24) | 1259 else if (recorder->get_nbits () == 24) |
1252 { | 1260 { |
1253 uint8_t *input24 = (uint8_t *)input; | 1261 // FIXME: Is there a better way? |
1262 const uint8_t *input24 = static_cast<const uint8_t *> (input); | |
1254 int32_t sample_l32, sample_r32; | 1263 int32_t sample_l32, sample_r32; |
1255 uint8_t *_sample_l = (uint8_t *)&sample_l; | 1264 uint8_t *_sample_l = reinterpret_cast<uint8_t *> (&sample_l); |
1256 uint8_t *_sample_r = (uint8_t *)&sample_r; | 1265 uint8_t *_sample_r = reinterpret_cast<uint8_t *> (&sample_r); |
1257 for (int i = 0; i < frames; i++) | 1266 for (int i = 0; i < frames; i++) |
1258 { | 1267 { |
1259 for (int j = 0; j < 3; j++) | 1268 for (int j = 0; j < 3; j++) |
1260 { | 1269 { |
1261 _sample_l[j] = input24[i * channels * 3 + j]; | 1270 _sample_l[j] = input24[i * channels * 3 + j]; |
1499 this->left.clear (); | 1508 this->left.clear (); |
1500 this->right.clear (); | 1509 this->right.clear (); |
1501 PaError err; | 1510 PaError err; |
1502 if (this->octave_callback_function != 0) | 1511 if (this->octave_callback_function != 0) |
1503 { | 1512 { |
1504 err = Pa_OpenStream (&stream, &(this->input_parameters), NULL, this->get_fs (), BUFFER_SIZE, paClipOff, octave_record_callback, (void *)this); | 1513 err = Pa_OpenStream (&stream, &(this->input_parameters), NULL, |
1514 this->get_fs (), BUFFER_SIZE, paClipOff, | |
1515 octave_record_callback, this); | |
1505 } | 1516 } |
1506 else | 1517 else |
1507 { | 1518 { |
1508 err = Pa_OpenStream (&stream, &(this->input_parameters), NULL, this->get_fs (), BUFFER_SIZE, paClipOff, portaudio_record_callback, (void *)this); | 1519 err = Pa_OpenStream (&stream, &(this->input_parameters), NULL, |
1520 this->get_fs (), BUFFER_SIZE, paClipOff, | |
1521 portaudio_record_callback, this); | |
1509 } | 1522 } |
1510 if (err != paNoError) | 1523 if (err != paNoError) |
1511 { | 1524 { |
1512 error ("audiorecorder: Error opening audio recording stream"); | 1525 error ("audiorecorder: Error opening audio recording stream"); |
1513 return; | 1526 return; |
1528 | 1541 |
1529 this->left.clear (); | 1542 this->left.clear (); |
1530 this->right.clear (); | 1543 this->right.clear (); |
1531 | 1544 |
1532 PaError err; | 1545 PaError err; |
1533 err = Pa_OpenStream (&stream, &(this->input_parameters), NULL, this->get_fs (), BUFFER_SIZE, paClipOff, NULL, (void *)this); | 1546 err = Pa_OpenStream (&stream, &(this->input_parameters), NULL, |
1547 this->get_fs (), BUFFER_SIZE, paClipOff, NULL, this); | |
1534 if (err != paNoError) | 1548 if (err != paNoError) |
1535 { | 1549 { |
1536 error ("audiorecorder: Error opening audio recording stream"); | 1550 error ("audiorecorder: Error opening audio recording stream"); |
1537 return; | 1551 return; |
1538 } | 1552 } |
1546 | 1560 |
1547 unsigned int frames = seconds * this->get_fs (); | 1561 unsigned int frames = seconds * this->get_fs (); |
1548 uint8_t buffer[BUFFER_SIZE * 2 * 3]; | 1562 uint8_t buffer[BUFFER_SIZE * 2 * 3]; |
1549 for (int i = 0; i < frames / BUFFER_SIZE; i++) | 1563 for (int i = 0; i < frames / BUFFER_SIZE; i++) |
1550 { | 1564 { |
1551 Pa_ReadStream (this->get_stream (), (void *)buffer, BUFFER_SIZE); | 1565 Pa_ReadStream (this->get_stream (), buffer, BUFFER_SIZE); |
1552 if (this->octave_callback_function != 0) | 1566 if (this->octave_callback_function != 0) |
1553 octave_record_callback ((void *)buffer, NULL, BUFFER_SIZE, 0, 0, (void *)this); | 1567 octave_record_callback (buffer, NULL, BUFFER_SIZE, 0, 0, this); |
1554 else | 1568 else |
1555 portaudio_record_callback ((void *)buffer, NULL, BUFFER_SIZE, 0, 0, (void *)this); | 1569 portaudio_record_callback (buffer, NULL, BUFFER_SIZE, 0, 0, this); |
1556 } | 1570 } |
1557 } | 1571 } |
1558 | 1572 |
1559 void | 1573 void |
1560 audiorecorder::pause (void) | 1574 audiorecorder::pause (void) |
1671 error ("portaudio not found on your system and thus audio functionality is not present"); | 1685 error ("portaudio not found on your system and thus audio functionality is not present"); |
1672 return retval; | 1686 return retval; |
1673 #endif | 1687 #endif |
1674 } | 1688 } |
1675 | 1689 |
1690 static audiorecorder * | |
1691 get_recorder (const octave_value& ov) | |
1692 { | |
1693 const octave_base_value& rep = ov.get_rep (); | |
1694 | |
1695 octave_base_value *ncrep = const_cast<octave_base_value *> (&rep); | |
1696 | |
1697 return dynamic_cast<audiorecorder *> (ncrep); | |
1698 } | |
1699 | |
1676 DEFUN_DLD (__recorder_getaudiodata__, args, , | 1700 DEFUN_DLD (__recorder_getaudiodata__, args, , |
1677 "-*- texinfo -*-\n\ | 1701 "-*- texinfo -*-\n\ |
1678 @deftypefn {Loadable Function} {@var{data}} __recorder_getaudiodata__ (@var{recorder})\n\ | 1702 @deftypefn {Loadable Function} {@var{data}} __recorder_getaudiodata__ (@var{recorder})\n\ |
1679 Undocumented internal function.\n\ | 1703 Undocumented internal function.\n\ |
1680 @end deftypefn") | 1704 @end deftypefn") |
1681 { | 1705 { |
1682 octave_value retval; | 1706 octave_value retval; |
1683 #ifdef HAVE_PORTAUDIO | 1707 #ifdef HAVE_PORTAUDIO |
1684 const octave_base_value& rep = args(0).get_rep (); | 1708 audiorecorder *recorder = get_recorder (args(0)); |
1685 audiorecorder *recorder = &((audiorecorder &)rep); | |
1686 retval = octave_value (recorder->getaudiodata ()); | 1709 retval = octave_value (recorder->getaudiodata ()); |
1687 #else | 1710 #else |
1688 error ("portaudio not found on your system and thus audio functionality is not present"); | 1711 error ("portaudio not found on your system and thus audio functionality is not present"); |
1689 #endif | 1712 #endif |
1690 return retval; | 1713 return retval; |
1699 octave_value retval; | 1722 octave_value retval; |
1700 #ifdef HAVE_PORTAUDIO | 1723 #ifdef HAVE_PORTAUDIO |
1701 int nargin = args.length (); | 1724 int nargin = args.length (); |
1702 if (nargin == 1) | 1725 if (nargin == 1) |
1703 { | 1726 { |
1704 const octave_base_value& rep = args(0).get_rep (); | 1727 audiorecorder *recorder = get_recorder (args(0)); |
1705 audiorecorder *recorder = &((audiorecorder &)rep); | |
1706 retval = octave_value (recorder->get_channels ()); | 1728 retval = octave_value (recorder->get_channels ()); |
1707 } | 1729 } |
1708 #else | 1730 #else |
1709 error ("portaudio not found on your system and thus audio functionality is not present"); | 1731 error ("portaudio not found on your system and thus audio functionality is not present"); |
1710 #endif | 1732 #endif |
1720 octave_value retval; | 1742 octave_value retval; |
1721 #ifdef HAVE_PORTAUDIO | 1743 #ifdef HAVE_PORTAUDIO |
1722 int nargin = args.length (); | 1744 int nargin = args.length (); |
1723 if (nargin == 1) | 1745 if (nargin == 1) |
1724 { | 1746 { |
1725 const octave_base_value& rep = args(0).get_rep (); | 1747 audiorecorder *recorder = get_recorder (args(0)); |
1726 audiorecorder *recorder = &((audiorecorder &)rep); | |
1727 retval = octave_value (recorder->get_fs ()); | 1748 retval = octave_value (recorder->get_fs ()); |
1728 } | 1749 } |
1729 #else | 1750 #else |
1730 error ("portaudio not found on your system and thus audio functionality is not present"); | 1751 error ("portaudio not found on your system and thus audio functionality is not present"); |
1731 #endif | 1752 #endif |
1741 octave_value retval; | 1762 octave_value retval; |
1742 #ifdef HAVE_PORTAUDIO | 1763 #ifdef HAVE_PORTAUDIO |
1743 int nargin = args.length (); | 1764 int nargin = args.length (); |
1744 if (nargin == 1) | 1765 if (nargin == 1) |
1745 { | 1766 { |
1746 const octave_base_value& rep = args(0).get_rep (); | 1767 audiorecorder *recorder = get_recorder (args(0)); |
1747 audiorecorder *recorder = &((audiorecorder &)rep); | |
1748 retval = octave_value (recorder->get_id ()); | 1768 retval = octave_value (recorder->get_id ()); |
1749 } | 1769 } |
1750 #else | 1770 #else |
1751 error ("portaudio not found on your system and thus audio functionality is not present"); | 1771 error ("portaudio not found on your system and thus audio functionality is not present"); |
1752 #endif | 1772 #endif |
1762 octave_value retval; | 1782 octave_value retval; |
1763 #ifdef HAVE_PORTAUDIO | 1783 #ifdef HAVE_PORTAUDIO |
1764 int nargin = args.length (); | 1784 int nargin = args.length (); |
1765 if (nargin == 1) | 1785 if (nargin == 1) |
1766 { | 1786 { |
1767 const octave_base_value& rep = args(0).get_rep (); | 1787 audiorecorder *recorder = get_recorder (args(0)); |
1768 audiorecorder *recorder = &((audiorecorder &)rep); | |
1769 retval = octave_value (recorder->get_nbits ()); | 1788 retval = octave_value (recorder->get_nbits ()); |
1770 } | 1789 } |
1771 #else | 1790 #else |
1772 error ("portaudio not found on your system and thus audio functionality is not present"); | 1791 error ("portaudio not found on your system and thus audio functionality is not present"); |
1773 #endif | 1792 #endif |
1783 octave_value retval; | 1802 octave_value retval; |
1784 #ifdef HAVE_PORTAUDIO | 1803 #ifdef HAVE_PORTAUDIO |
1785 int nargin = args.length (); | 1804 int nargin = args.length (); |
1786 if (nargin == 1) | 1805 if (nargin == 1) |
1787 { | 1806 { |
1788 const octave_base_value& rep = args(0).get_rep (); | 1807 audiorecorder *recorder = get_recorder (args(0)); |
1789 audiorecorder *recorder = &((audiorecorder &)rep); | |
1790 retval = octave_value (recorder->get_sample_number ()); | 1808 retval = octave_value (recorder->get_sample_number ()); |
1791 } | 1809 } |
1792 #else | 1810 #else |
1793 error ("portaudio not found on your system and thus audio functionality is not present"); | 1811 error ("portaudio not found on your system and thus audio functionality is not present"); |
1794 #endif | 1812 #endif |
1804 octave_value retval; | 1822 octave_value retval; |
1805 #ifdef HAVE_PORTAUDIO | 1823 #ifdef HAVE_PORTAUDIO |
1806 int nargin = args.length (); | 1824 int nargin = args.length (); |
1807 if (nargin == 1) | 1825 if (nargin == 1) |
1808 { | 1826 { |
1809 const octave_base_value& rep = args(0).get_rep (); | 1827 audiorecorder *recorder = get_recorder (args(0)); |
1810 audiorecorder *recorder = &((audiorecorder &)rep); | |
1811 retval = octave_value (recorder->get_tag ()); | 1828 retval = octave_value (recorder->get_tag ()); |
1812 } | 1829 } |
1813 #else | 1830 #else |
1814 error ("portaudio not found on your system and thus audio functionality is not present"); | 1831 error ("portaudio not found on your system and thus audio functionality is not present"); |
1815 #endif | 1832 #endif |
1825 octave_value retval; | 1842 octave_value retval; |
1826 #ifdef HAVE_PORTAUDIO | 1843 #ifdef HAVE_PORTAUDIO |
1827 int nargin = args.length (); | 1844 int nargin = args.length (); |
1828 if (nargin == 1) | 1845 if (nargin == 1) |
1829 { | 1846 { |
1830 const octave_base_value& rep = args(0).get_rep (); | 1847 audiorecorder *recorder = get_recorder (args(0)); |
1831 audiorecorder *recorder = &((audiorecorder &)rep); | |
1832 retval = octave_value (recorder->get_total_samples ()); | 1848 retval = octave_value (recorder->get_total_samples ()); |
1833 } | 1849 } |
1834 #else | 1850 #else |
1835 error ("portaudio not found on your system and thus audio functionality is not present"); | 1851 error ("portaudio not found on your system and thus audio functionality is not present"); |
1836 #endif | 1852 #endif |
1846 octave_value retval; | 1862 octave_value retval; |
1847 #ifdef HAVE_PORTAUDIO | 1863 #ifdef HAVE_PORTAUDIO |
1848 int nargin = args.length (); | 1864 int nargin = args.length (); |
1849 if (nargin == 1) | 1865 if (nargin == 1) |
1850 { | 1866 { |
1851 const octave_base_value& rep = args(0).get_rep (); | 1867 audiorecorder *recorder = get_recorder (args(0)); |
1852 audiorecorder *recorder = &((audiorecorder &)rep); | |
1853 retval = recorder->get_userdata (); | 1868 retval = recorder->get_userdata (); |
1854 } | 1869 } |
1855 #else | 1870 #else |
1856 error ("portaudio not found on your system and thus audio functionality is not present"); | 1871 error ("portaudio not found on your system and thus audio functionality is not present"); |
1857 #endif | 1872 #endif |
1867 octave_value retval; | 1882 octave_value retval; |
1868 #ifdef HAVE_PORTAUDIO | 1883 #ifdef HAVE_PORTAUDIO |
1869 int nargin = args.length (); | 1884 int nargin = args.length (); |
1870 if (nargin == 1) | 1885 if (nargin == 1) |
1871 { | 1886 { |
1872 const octave_base_value& rep = args(0).get_rep (); | 1887 audiorecorder *recorder = get_recorder (args(0)); |
1873 audiorecorder *recorder = &((audiorecorder &)rep); | |
1874 if (recorder->isrecording ()) | 1888 if (recorder->isrecording ()) |
1875 return octave_value (1); | 1889 return octave_value (1); |
1876 else | 1890 else |
1877 return octave_value (0); | 1891 return octave_value (0); |
1878 } | 1892 } |
1891 octave_value retval; | 1905 octave_value retval; |
1892 #ifdef HAVE_PORTAUDIO | 1906 #ifdef HAVE_PORTAUDIO |
1893 int nargin = args.length (); | 1907 int nargin = args.length (); |
1894 if (nargin == 1) | 1908 if (nargin == 1) |
1895 { | 1909 { |
1896 const octave_base_value& rep = args(0).get_rep (); | 1910 audiorecorder *recorder = get_recorder (args(0)); |
1897 audiorecorder *recorder = &((audiorecorder &)rep); | |
1898 recorder->pause (); | 1911 recorder->pause (); |
1899 } | 1912 } |
1900 #else | 1913 #else |
1901 error ("portaudio not found on your system and thus audio functionality is not present"); | 1914 error ("portaudio not found on your system and thus audio functionality is not present"); |
1902 #endif | 1915 #endif |
1909 Undocumented internal function.\n\ | 1922 Undocumented internal function.\n\ |
1910 @end deftypefn") | 1923 @end deftypefn") |
1911 { | 1924 { |
1912 octave_value retval; | 1925 octave_value retval; |
1913 #ifdef HAVE_PORTAUDIO | 1926 #ifdef HAVE_PORTAUDIO |
1914 const octave_base_value& rep = args(0).get_rep (); | 1927 audiorecorder *recorder = get_recorder (args(0)); |
1915 audiorecorder *recorder = &((audiorecorder &)rep); | |
1916 recorder->recordblocking (args(1).float_value ()); | 1928 recorder->recordblocking (args(1).float_value ()); |
1917 #else | 1929 #else |
1918 error ("portaudio not found on your system and thus audio functionality is not present"); | 1930 error ("portaudio not found on your system and thus audio functionality is not present"); |
1919 #endif | 1931 #endif |
1920 return retval; | 1932 return retval; |
1927 Undocumented internal function.\n\ | 1939 Undocumented internal function.\n\ |
1928 @end deftypefn") | 1940 @end deftypefn") |
1929 { | 1941 { |
1930 octave_value retval; | 1942 octave_value retval; |
1931 #ifdef HAVE_PORTAUDIO | 1943 #ifdef HAVE_PORTAUDIO |
1932 const octave_base_value& rep = args(0).get_rep (); | 1944 audiorecorder *recorder = get_recorder (args(0)); |
1933 audiorecorder *recorder = &((audiorecorder &)rep); | |
1934 if (args.length () == 1) | 1945 if (args.length () == 1) |
1935 { | 1946 { |
1936 recorder->record (); | 1947 recorder->record (); |
1937 } | 1948 } |
1938 else if (args.length () == 2) | 1949 else if (args.length () == 2) |
1959 octave_value retval; | 1970 octave_value retval; |
1960 #ifdef HAVE_PORTAUDIO | 1971 #ifdef HAVE_PORTAUDIO |
1961 int nargin = args.length (); | 1972 int nargin = args.length (); |
1962 if (nargin == 1) | 1973 if (nargin == 1) |
1963 { | 1974 { |
1964 const octave_base_value& rep = args(0).get_rep (); | 1975 audiorecorder *recorder = get_recorder (args(0)); |
1965 audiorecorder *recorder = &((audiorecorder &)rep); | |
1966 recorder->resume (); | 1976 recorder->resume (); |
1967 } | 1977 } |
1968 #else | 1978 #else |
1969 error ("portaudio not found on your system and thus audio functionality is not present"); | 1979 error ("portaudio not found on your system and thus audio functionality is not present"); |
1970 #endif | 1980 #endif |
1980 octave_value retval; | 1990 octave_value retval; |
1981 #ifdef HAVE_PORTAUDIO | 1991 #ifdef HAVE_PORTAUDIO |
1982 int nargin = args.length (); | 1992 int nargin = args.length (); |
1983 if (nargin == 2) | 1993 if (nargin == 2) |
1984 { | 1994 { |
1985 const octave_base_value& rep = args(0).get_rep (); | 1995 audiorecorder *recorder = get_recorder (args(0)); |
1986 audiorecorder *recorder = &((audiorecorder &)rep); | |
1987 recorder->set_fs (args(1).int_value ()); | 1996 recorder->set_fs (args(1).int_value ()); |
1988 } | 1997 } |
1989 #else | 1998 #else |
1990 error ("portaudio not found on your system and thus audio functionality is not present"); | 1999 error ("portaudio not found on your system and thus audio functionality is not present"); |
1991 #endif | 2000 #endif |
2001 octave_value retval; | 2010 octave_value retval; |
2002 #ifdef HAVE_PORTAUDIO | 2011 #ifdef HAVE_PORTAUDIO |
2003 int nargin = args.length (); | 2012 int nargin = args.length (); |
2004 if (nargin == 2) | 2013 if (nargin == 2) |
2005 { | 2014 { |
2006 const octave_base_value& rep = args(0).get_rep (); | 2015 audiorecorder *recorder = get_recorder (args(0)); |
2007 audiorecorder *recorder = &((audiorecorder &)rep); | |
2008 recorder->set_tag (args(1).char_matrix_value ()); | 2016 recorder->set_tag (args(1).char_matrix_value ()); |
2009 } | 2017 } |
2010 #else | 2018 #else |
2011 error ("portaudio not found on your system and thus audio functionality is not present"); | 2019 error ("portaudio not found on your system and thus audio functionality is not present"); |
2012 #endif | 2020 #endif |
2022 octave_value retval; | 2030 octave_value retval; |
2023 #ifdef HAVE_PORTAUDIO | 2031 #ifdef HAVE_PORTAUDIO |
2024 int nargin = args.length (); | 2032 int nargin = args.length (); |
2025 if (nargin == 2) | 2033 if (nargin == 2) |
2026 { | 2034 { |
2027 const octave_base_value& rep = args(0).get_rep (); | 2035 audiorecorder *recorder = get_recorder (args(0)); |
2028 audiorecorder *recorder = &((audiorecorder &)rep); | |
2029 recorder->set_userdata (args(1)); | 2036 recorder->set_userdata (args(1)); |
2030 } | 2037 } |
2031 #else | 2038 #else |
2032 error ("portaudio not found on your system and thus audio functionality is not present"); | 2039 error ("portaudio not found on your system and thus audio functionality is not present"); |
2033 #endif | 2040 #endif |
2040 Undocumented internal function.\n\ | 2047 Undocumented internal function.\n\ |
2041 @end deftypefn") | 2048 @end deftypefn") |
2042 { | 2049 { |
2043 octave_value retval; | 2050 octave_value retval; |
2044 #ifdef HAVE_PORTAUDIO | 2051 #ifdef HAVE_PORTAUDIO |
2045 const octave_base_value& rep = args(0).get_rep (); | 2052 audiorecorder *recorder = get_recorder (args(0)); |
2046 audiorecorder *recorder = &((audiorecorder &)rep); | |
2047 recorder->stop (); | 2053 recorder->stop (); |
2048 #else | 2054 #else |
2049 error ("portaudio not found on your system and thus audio functionality is not present"); | 2055 error ("portaudio not found on your system and thus audio functionality is not present"); |
2050 #endif | 2056 #endif |
2051 return retval; | 2057 return retval; |
2088 error ("portaudio not found on your system and thus audio functionality is not present"); | 2094 error ("portaudio not found on your system and thus audio functionality is not present"); |
2089 return retval; | 2095 return retval; |
2090 #endif | 2096 #endif |
2091 } | 2097 } |
2092 | 2098 |
2099 static audioplayer * | |
2100 get_player (const octave_value& ov) | |
2101 { | |
2102 const octave_base_value& rep = ov.get_rep (); | |
2103 | |
2104 octave_base_value *ncrep = const_cast<octave_base_value *> (&rep); | |
2105 | |
2106 return dynamic_cast<audioplayer *> (ncrep); | |
2107 } | |
2108 | |
2093 DEFUN_DLD (__player_get_channels__, args, , | 2109 DEFUN_DLD (__player_get_channels__, args, , |
2094 "-*- texinfo -*-\n\ | 2110 "-*- texinfo -*-\n\ |
2095 @deftypefn {Loadable Function} {@var{n} =} __player_get_channels__ (@var{player})\n\ | 2111 @deftypefn {Loadable Function} {@var{n} =} __player_get_channels__ (@var{player})\n\ |
2096 Undocumented internal function.\n\ | 2112 Undocumented internal function.\n\ |
2097 @end deftypefn") | 2113 @end deftypefn") |
2099 octave_value retval; | 2115 octave_value retval; |
2100 #ifdef HAVE_PORTAUDIO | 2116 #ifdef HAVE_PORTAUDIO |
2101 int nargin = args.length (); | 2117 int nargin = args.length (); |
2102 if (nargin == 1) | 2118 if (nargin == 1) |
2103 { | 2119 { |
2104 const octave_base_value& rep = args(0).get_rep (); | 2120 audioplayer *player = get_player (args(0)); |
2105 audioplayer *player = &((audioplayer &)rep); | |
2106 retval = octave_value (player->get_channels ()); | 2121 retval = octave_value (player->get_channels ()); |
2107 } | 2122 } |
2108 #else | 2123 #else |
2109 error ("portaudio not found on your system and thus audio functionality is not present"); | 2124 error ("portaudio not found on your system and thus audio functionality is not present"); |
2110 #endif | 2125 #endif |
2120 octave_value retval; | 2135 octave_value retval; |
2121 #ifdef HAVE_PORTAUDIO | 2136 #ifdef HAVE_PORTAUDIO |
2122 int nargin = args.length (); | 2137 int nargin = args.length (); |
2123 if (nargin == 1) | 2138 if (nargin == 1) |
2124 { | 2139 { |
2125 const octave_base_value& rep = args(0).get_rep (); | 2140 audioplayer *player = get_player (args(0)); |
2126 audioplayer *player = &((audioplayer &)rep); | |
2127 retval = octave_value (player->get_fs ()); | 2141 retval = octave_value (player->get_fs ()); |
2128 } | 2142 } |
2129 #else | 2143 #else |
2130 error ("portaudio not found on your system and thus audio functionality is not present"); | 2144 error ("portaudio not found on your system and thus audio functionality is not present"); |
2131 #endif | 2145 #endif |
2141 octave_value retval; | 2155 octave_value retval; |
2142 #ifdef HAVE_PORTAUDIO | 2156 #ifdef HAVE_PORTAUDIO |
2143 int nargin = args.length (); | 2157 int nargin = args.length (); |
2144 if (nargin == 1) | 2158 if (nargin == 1) |
2145 { | 2159 { |
2146 const octave_base_value& rep = args(0).get_rep (); | 2160 audioplayer *player = get_player (args(0)); |
2147 audioplayer *player = &((audioplayer &)rep); | |
2148 retval = octave_value (player->get_id ()); | 2161 retval = octave_value (player->get_id ()); |
2149 } | 2162 } |
2150 #else | 2163 #else |
2151 error ("portaudio not found on your system and thus audio functionality is not present"); | 2164 error ("portaudio not found on your system and thus audio functionality is not present"); |
2152 #endif | 2165 #endif |
2162 octave_value retval; | 2175 octave_value retval; |
2163 #ifdef HAVE_PORTAUDIO | 2176 #ifdef HAVE_PORTAUDIO |
2164 int nargin = args.length (); | 2177 int nargin = args.length (); |
2165 if (nargin == 1) | 2178 if (nargin == 1) |
2166 { | 2179 { |
2167 const octave_base_value& rep = args(0).get_rep (); | 2180 audioplayer *player = get_player (args(0)); |
2168 audioplayer *player = &((audioplayer &)rep); | |
2169 retval = octave_value (player->get_nbits ()); | 2181 retval = octave_value (player->get_nbits ()); |
2170 } | 2182 } |
2171 #else | 2183 #else |
2172 error ("portaudio not found on your system and thus audio functionality is not present"); | 2184 error ("portaudio not found on your system and thus audio functionality is not present"); |
2173 #endif | 2185 #endif |
2183 octave_value retval; | 2195 octave_value retval; |
2184 #ifdef HAVE_PORTAUDIO | 2196 #ifdef HAVE_PORTAUDIO |
2185 int nargin = args.length (); | 2197 int nargin = args.length (); |
2186 if (nargin == 1) | 2198 if (nargin == 1) |
2187 { | 2199 { |
2188 const octave_base_value& rep = args(0).get_rep (); | 2200 audioplayer *player = get_player (args(0)); |
2189 audioplayer *player = &((audioplayer &)rep); | |
2190 retval = octave_value (player->get_sample_number ()); | 2201 retval = octave_value (player->get_sample_number ()); |
2191 } | 2202 } |
2192 #else | 2203 #else |
2193 error ("portaudio not found on your system and thus audio functionality is not present"); | 2204 error ("portaudio not found on your system and thus audio functionality is not present"); |
2194 #endif | 2205 #endif |
2204 octave_value retval; | 2215 octave_value retval; |
2205 #ifdef HAVE_PORTAUDIO | 2216 #ifdef HAVE_PORTAUDIO |
2206 int nargin = args.length (); | 2217 int nargin = args.length (); |
2207 if (nargin == 1) | 2218 if (nargin == 1) |
2208 { | 2219 { |
2209 const octave_base_value& rep = args(0).get_rep (); | 2220 audioplayer *player = get_player (args(0)); |
2210 audioplayer *player = &((audioplayer &)rep); | |
2211 retval = octave_value (player->get_tag ()); | 2221 retval = octave_value (player->get_tag ()); |
2212 } | 2222 } |
2213 #else | 2223 #else |
2214 error ("portaudio not found on your system and thus audio functionality is not present"); | 2224 error ("portaudio not found on your system and thus audio functionality is not present"); |
2215 #endif | 2225 #endif |
2225 octave_value retval; | 2235 octave_value retval; |
2226 #ifdef HAVE_PORTAUDIO | 2236 #ifdef HAVE_PORTAUDIO |
2227 int nargin = args.length (); | 2237 int nargin = args.length (); |
2228 if (nargin == 1) | 2238 if (nargin == 1) |
2229 { | 2239 { |
2230 const octave_base_value& rep = args(0).get_rep (); | 2240 audioplayer *player = get_player (args(0)); |
2231 audioplayer *player = &((audioplayer &)rep); | |
2232 retval = octave_value (player->get_total_samples ()); | 2241 retval = octave_value (player->get_total_samples ()); |
2233 } | 2242 } |
2234 #else | 2243 #else |
2235 error ("portaudio not found on your system and thus audio functionality is not present"); | 2244 error ("portaudio not found on your system and thus audio functionality is not present"); |
2236 #endif | 2245 #endif |
2246 octave_value retval; | 2255 octave_value retval; |
2247 #ifdef HAVE_PORTAUDIO | 2256 #ifdef HAVE_PORTAUDIO |
2248 int nargin = args.length (); | 2257 int nargin = args.length (); |
2249 if (nargin == 1) | 2258 if (nargin == 1) |
2250 { | 2259 { |
2251 const octave_base_value& rep = args(0).get_rep (); | 2260 audioplayer *player = get_player (args(0)); |
2252 audioplayer *player = &((audioplayer &)rep); | |
2253 retval = player->get_userdata (); | 2261 retval = player->get_userdata (); |
2254 } | 2262 } |
2255 #else | 2263 #else |
2256 error ("portaudio not found on your system and thus audio functionality is not present"); | 2264 error ("portaudio not found on your system and thus audio functionality is not present"); |
2257 #endif | 2265 #endif |
2267 octave_value retval; | 2275 octave_value retval; |
2268 #ifdef HAVE_PORTAUDIO | 2276 #ifdef HAVE_PORTAUDIO |
2269 int nargin = args.length (); | 2277 int nargin = args.length (); |
2270 if (nargin == 1) | 2278 if (nargin == 1) |
2271 { | 2279 { |
2272 const octave_base_value& rep = args(0).get_rep (); | 2280 audioplayer *player = get_player (args(0)); |
2273 audioplayer *player = &((audioplayer &)rep); | |
2274 if (player->isplaying ()) | 2281 if (player->isplaying ()) |
2275 return octave_value (1); | 2282 return octave_value (1); |
2276 else | 2283 else |
2277 return octave_value (0); | 2284 return octave_value (0); |
2278 } | 2285 } |
2291 octave_value retval; | 2298 octave_value retval; |
2292 #ifdef HAVE_PORTAUDIO | 2299 #ifdef HAVE_PORTAUDIO |
2293 int nargin = args.length (); | 2300 int nargin = args.length (); |
2294 if (nargin == 1) | 2301 if (nargin == 1) |
2295 { | 2302 { |
2296 const octave_base_value& rep = args(0).get_rep (); | 2303 audioplayer *player = get_player (args(0)); |
2297 audioplayer *player = &((audioplayer &)rep); | |
2298 player->pause (); | 2304 player->pause (); |
2299 } | 2305 } |
2300 #else | 2306 #else |
2301 error ("portaudio not found on your system and thus audio functionality is not present"); | 2307 error ("portaudio not found on your system and thus audio functionality is not present"); |
2302 #endif | 2308 #endif |
2314 octave_value retval; | 2320 octave_value retval; |
2315 #ifdef HAVE_PORTAUDIO | 2321 #ifdef HAVE_PORTAUDIO |
2316 int nargin = args.length (); | 2322 int nargin = args.length (); |
2317 if (nargin == 1) | 2323 if (nargin == 1) |
2318 { | 2324 { |
2319 const octave_base_value& rep = args(0).get_rep (); | 2325 audioplayer *player = get_player (args(0)); |
2320 audioplayer *player = &((audioplayer &)rep); | |
2321 player->playblocking (); | 2326 player->playblocking (); |
2322 } | 2327 } |
2323 else | 2328 else |
2324 { | 2329 { |
2325 const octave_base_value& rep = args(0).get_rep (); | 2330 audioplayer *player = get_player (args(0)); |
2326 audioplayer *player = &((audioplayer &)rep); | |
2327 if (args(1).is_matrix_type ()) | 2331 if (args(1).is_matrix_type ()) |
2328 { | 2332 { |
2329 unsigned int start, end; | 2333 unsigned int start, end; |
2330 RowVector range = args(1).row_vector_value (); | 2334 RowVector range = args(1).row_vector_value (); |
2331 start = range.elem (0) - 1; | 2335 start = range.elem (0) - 1; |
2363 octave_value retval; | 2367 octave_value retval; |
2364 #ifdef HAVE_PORTAUDIO | 2368 #ifdef HAVE_PORTAUDIO |
2365 int nargin = args.length (); | 2369 int nargin = args.length (); |
2366 if (nargin == 1) | 2370 if (nargin == 1) |
2367 { | 2371 { |
2368 const octave_base_value& rep = args(0).get_rep (); | 2372 audioplayer *player = get_player (args(0)); |
2369 audioplayer *player = &((audioplayer &)rep); | |
2370 player->play (); | 2373 player->play (); |
2371 } | 2374 } |
2372 else | 2375 else |
2373 { | 2376 { |
2374 const octave_base_value& rep = args(0).get_rep (); | 2377 audioplayer *player = get_player (args(0)); |
2375 audioplayer *player = &((audioplayer &)rep); | |
2376 if (args(1).is_matrix_type ()) | 2378 if (args(1).is_matrix_type ()) |
2377 { | 2379 { |
2378 unsigned int start, end; | 2380 unsigned int start, end; |
2379 RowVector range = args(1).row_vector_value (); | 2381 RowVector range = args(1).row_vector_value (); |
2380 start = range.elem (0) - 1; | 2382 start = range.elem (0) - 1; |
2410 octave_value retval; | 2412 octave_value retval; |
2411 #ifdef HAVE_PORTAUDIO | 2413 #ifdef HAVE_PORTAUDIO |
2412 int nargin = args.length (); | 2414 int nargin = args.length (); |
2413 if (nargin == 1) | 2415 if (nargin == 1) |
2414 { | 2416 { |
2415 const octave_base_value& rep = args(0).get_rep (); | 2417 audioplayer *player = get_player (args(0)); |
2416 audioplayer *player = &((audioplayer &)rep); | |
2417 player->resume (); | 2418 player->resume (); |
2418 } | 2419 } |
2419 #else | 2420 #else |
2420 error ("portaudio not found on your system and thus audio functionality is not present"); | 2421 error ("portaudio not found on your system and thus audio functionality is not present"); |
2421 #endif | 2422 #endif |
2431 octave_value retval; | 2432 octave_value retval; |
2432 #ifdef HAVE_PORTAUDIO | 2433 #ifdef HAVE_PORTAUDIO |
2433 int nargin = args.length (); | 2434 int nargin = args.length (); |
2434 if (nargin == 2) | 2435 if (nargin == 2) |
2435 { | 2436 { |
2436 const octave_base_value& rep = args(0).get_rep (); | 2437 audioplayer *player = get_player (args(0)); |
2437 audioplayer *player = &((audioplayer &)rep); | |
2438 player->set_fs (args(1).int_value ()); | 2438 player->set_fs (args(1).int_value ()); |
2439 } | 2439 } |
2440 #else | 2440 #else |
2441 error ("portaudio not found on your system and thus audio functionality is not present"); | 2441 error ("portaudio not found on your system and thus audio functionality is not present"); |
2442 #endif | 2442 #endif |
2452 octave_value retval; | 2452 octave_value retval; |
2453 #ifdef HAVE_PORTAUDIO | 2453 #ifdef HAVE_PORTAUDIO |
2454 int nargin = args.length (); | 2454 int nargin = args.length (); |
2455 if (nargin == 2) | 2455 if (nargin == 2) |
2456 { | 2456 { |
2457 const octave_base_value& rep = args(0).get_rep (); | 2457 audioplayer *player = get_player (args(0)); |
2458 audioplayer *player = &((audioplayer &)rep); | |
2459 player->set_tag (args(1).char_matrix_value ()); | 2458 player->set_tag (args(1).char_matrix_value ()); |
2460 } | 2459 } |
2461 #else | 2460 #else |
2462 error ("portaudio not found on your system and thus audio functionality is not present"); | 2461 error ("portaudio not found on your system and thus audio functionality is not present"); |
2463 #endif | 2462 #endif |
2473 octave_value retval; | 2472 octave_value retval; |
2474 #ifdef HAVE_PORTAUDIO | 2473 #ifdef HAVE_PORTAUDIO |
2475 int nargin = args.length (); | 2474 int nargin = args.length (); |
2476 if (nargin == 2) | 2475 if (nargin == 2) |
2477 { | 2476 { |
2478 const octave_base_value& rep = args(0).get_rep (); | 2477 audioplayer *player = get_player (args(0)); |
2479 audioplayer *player = &((audioplayer &)rep); | |
2480 player->set_userdata (args(1)); | 2478 player->set_userdata (args(1)); |
2481 } | 2479 } |
2482 #else | 2480 #else |
2483 error ("portaudio not found on your system and thus audio functionality is not present"); | 2481 error ("portaudio not found on your system and thus audio functionality is not present"); |
2484 #endif | 2482 #endif |
2494 octave_value retval; | 2492 octave_value retval; |
2495 #ifdef HAVE_PORTAUDIO | 2493 #ifdef HAVE_PORTAUDIO |
2496 int nargin = args.length (); | 2494 int nargin = args.length (); |
2497 if (nargin == 1) | 2495 if (nargin == 1) |
2498 { | 2496 { |
2499 const octave_base_value& rep = args(0).get_rep (); | 2497 audioplayer *player = get_player (args (0)); |
2500 audioplayer *player = &((audioplayer &)rep); | |
2501 player->stop (); | 2498 player->stop (); |
2502 } | 2499 } |
2503 #else | 2500 #else |
2504 error ("portaudio not found on your system and thus audio functionality is not present"); | 2501 error ("portaudio not found on your system and thus audio functionality is not present"); |
2505 #endif | 2502 #endif |