Mercurial > octave-nkf
comparison libinterp/dldfcn/audiodevinfo.cc @ 19591:182abae666ae
* audiodevinfo.cc: Explicitly use std::pow.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 09 Jan 2015 13:29:03 -0500 |
parents | d7057df2968e |
children | 0b068273340f |
comparison
equal
deleted
inserted
replaced
19590:d7057df2968e | 19591:182abae666ae |
---|---|
562 | 562 |
563 switch (player->get_nbits ()) | 563 switch (player->get_nbits ()) |
564 { | 564 { |
565 case 8: | 565 case 8: |
566 { | 566 { |
567 static double scale_factor = pow (2.0, 7) - 1.0; | 567 static double scale_factor = std::pow (2.0, 7) - 1.0; |
568 | 568 |
569 int8_t *buffer = static_cast<int8_t *> (output); | 569 int8_t *buffer = static_cast<int8_t *> (output); |
570 | 570 |
571 for (unsigned long i = 0; i < frames; i++) | 571 for (unsigned long i = 0; i < frames; i++) |
572 { | 572 { |
576 } | 576 } |
577 break; | 577 break; |
578 | 578 |
579 case 16: | 579 case 16: |
580 { | 580 { |
581 static double scale_factor = pow (2.0, 15) - 1.0; | 581 static double scale_factor = std::pow (2.0, 15) - 1.0; |
582 | 582 |
583 int16_t *buffer = static_cast<int16_t *> (output); | 583 int16_t *buffer = static_cast<int16_t *> (output); |
584 | 584 |
585 for (unsigned long i = 0; i < frames; i++) | 585 for (unsigned long i = 0; i < frames; i++) |
586 { | 586 { |
590 } | 590 } |
591 break; | 591 break; |
592 | 592 |
593 case 24: | 593 case 24: |
594 { | 594 { |
595 static double scale_factor = pow (2.0, 23) - 1.0; | 595 static double scale_factor = std::pow (2.0, 23) - 1.0; |
596 | 596 |
597 static int big_endian = oct_mach_info::words_big_endian (); | 597 static int big_endian = oct_mach_info::words_big_endian (); |
598 | 598 |
599 uint8_t *buffer = static_cast<uint8_t *> (output); | 599 uint8_t *buffer = static_cast<uint8_t *> (output); |
600 | 600 |
660 { | 660 { |
661 switch (player->get_nbits ()) | 661 switch (player->get_nbits ()) |
662 { | 662 { |
663 case 8: | 663 case 8: |
664 { | 664 { |
665 static double scale_factor = pow (2.0, 7) - 1.0; | 665 static double scale_factor = std::pow (2.0, 7) - 1.0; |
666 | 666 |
667 int8_t *buffer = static_cast<int8_t *> (output); | 667 int8_t *buffer = static_cast<int8_t *> (output); |
668 | 668 |
669 for (unsigned long j = 0; j < frames; j++) | 669 for (unsigned long j = 0; j < frames; j++) |
670 { | 670 { |
683 } | 683 } |
684 break; | 684 break; |
685 | 685 |
686 case 16: | 686 case 16: |
687 { | 687 { |
688 static double scale_factor = pow (2.0, 15) - 1.0; | 688 static double scale_factor = std::pow (2.0, 15) - 1.0; |
689 | 689 |
690 int16_t *buffer = static_cast<int16_t *> (output); | 690 int16_t *buffer = static_cast<int16_t *> (output); |
691 | 691 |
692 for (unsigned long j = 0; j < frames; j++) | 692 for (unsigned long j = 0; j < frames; j++) |
693 { | 693 { |
706 } | 706 } |
707 break; | 707 break; |
708 | 708 |
709 case 24: | 709 case 24: |
710 { | 710 { |
711 static double scale_factor = pow (2.0, 23) - 1.0; | 711 static double scale_factor = std::pow (2.0, 23) - 1.0; |
712 | 712 |
713 static int big_endian = oct_mach_info::words_big_endian (); | 713 static int big_endian = oct_mach_info::words_big_endian (); |
714 | 714 |
715 uint8_t *buffer = static_cast<uint8_t *> (output); | 715 uint8_t *buffer = static_cast<uint8_t *> (output); |
716 | 716 |
1317 if (recorder->get_nbits () == 8) | 1317 if (recorder->get_nbits () == 8) |
1318 { | 1318 { |
1319 const int8_t *input8 = static_cast<const int8_t *> (input); | 1319 const int8_t *input8 = static_cast<const int8_t *> (input); |
1320 for (unsigned long i = 0; i < frames; i++) | 1320 for (unsigned long i = 0; i < frames; i++) |
1321 { | 1321 { |
1322 sample_l = input8[i * channels] / (pow (2.0, 7) - 1.0); | 1322 sample_l = input8[i * channels] / (std::pow (2.0, 7) - 1.0); |
1323 sample_r = input8[i * channels + (channels - 1)] / (pow (2.0, 7) - 1.0); | 1323 sample_r = input8[i * channels + (channels - 1)] |
1324 / (std::pow (2.0, 7) - 1.0); | |
1325 | |
1324 sound(i, 0) = sample_l; | 1326 sound(i, 0) = sample_l; |
1325 sound(i, 1) = sample_r; | 1327 sound(i, 1) = sample_r; |
1326 } | 1328 } |
1327 } | 1329 } |
1328 else if (recorder->get_nbits () == 16) | 1330 else if (recorder->get_nbits () == 16) |
1329 { | 1331 { |
1330 const int16_t *input16 = static_cast<const int16_t *> (input); | 1332 const int16_t *input16 = static_cast<const int16_t *> (input); |
1331 for (unsigned long i = 0; i < frames; i++) | 1333 for (unsigned long i = 0; i < frames; i++) |
1332 { | 1334 { |
1333 sample_l = input16[i * channels] / (pow (2.0, 15) - 1.0); | 1335 sample_l = input16[i * channels] / (std::pow (2.0, 15) - 1.0); |
1334 sample_r = input16[i * channels + (channels - 1)] / (pow (2.0, 15) - 1.0); | 1336 sample_r = input16[i * channels + (channels - 1)] |
1337 / (std::pow (2.0, 15) - 1.0); | |
1338 | |
1335 sound(i, 0) = sample_l; | 1339 sound(i, 0) = sample_l; |
1336 sound(i, 1) = sample_r; | 1340 sound(i, 1) = sample_r; |
1337 } | 1341 } |
1338 } | 1342 } |
1339 else if (recorder->get_nbits () == 24) | 1343 else if (recorder->get_nbits () == 24) |
1357 sample_l32 |= 0xff000000; | 1361 sample_l32 |= 0xff000000; |
1358 | 1362 |
1359 if (sample_r32 & 0x00800000) | 1363 if (sample_r32 & 0x00800000) |
1360 sample_r32 |= 0xff000000; | 1364 sample_r32 |= 0xff000000; |
1361 | 1365 |
1362 sound(i, 0) = sample_l32 / pow (2.0, 23); | 1366 sound(i, 0) = sample_l32 / std::pow (2.0, 23); |
1363 sound(i, 1) = sample_r32 / pow (2.0, 23); | 1367 sound(i, 1) = sample_r32 / std::pow (2.0, 23); |
1364 } | 1368 } |
1365 } | 1369 } |
1366 | 1370 |
1367 octave_value_list args, retval; | 1371 octave_value_list args, retval; |
1368 args(0) = sound; | 1372 args(0) = sound; |
1382 if (recorder->get_nbits () == 8) | 1386 if (recorder->get_nbits () == 8) |
1383 { | 1387 { |
1384 const int8_t *input8 = static_cast<const int8_t *> (input); | 1388 const int8_t *input8 = static_cast<const int8_t *> (input); |
1385 for (unsigned long i = 0; i < frames; i++) | 1389 for (unsigned long i = 0; i < frames; i++) |
1386 { | 1390 { |
1387 sample_l = input8[i * channels] / (pow (2.0, 7) - 1.0); | 1391 sample_l = input8[i * channels] / (std::pow (2.0, 7) - 1.0); |
1388 sample_r = input8[i * channels + (channels - 1)] / (pow (2.0, 7) - 1.0); | 1392 sample_r = input8[i * channels + (channels - 1)] |
1393 / (std::pow (2.0, 7) - 1.0); | |
1394 | |
1389 recorder->append (sample_l, sample_r); | 1395 recorder->append (sample_l, sample_r); |
1390 } | 1396 } |
1391 } | 1397 } |
1392 else if (recorder->get_nbits () == 16) | 1398 else if (recorder->get_nbits () == 16) |
1393 { | 1399 { |
1394 const int16_t *input16 = static_cast<const int16_t *> (input); | 1400 const int16_t *input16 = static_cast<const int16_t *> (input); |
1395 for (unsigned long i = 0; i < frames; i++) | 1401 for (unsigned long i = 0; i < frames; i++) |
1396 { | 1402 { |
1397 sample_l = input16[i * channels] / (pow (2.0, 15) - 1.0); | 1403 sample_l = input16[i * channels] / (std::pow (2.0, 15) - 1.0); |
1398 sample_r = input16[i * channels + (channels - 1)] / (pow (2.0, 15) - 1.0); | 1404 sample_r = input16[i * channels + (channels - 1)] |
1405 / (std::pow (2.0, 15) - 1.0); | |
1406 | |
1399 recorder->append (sample_l, sample_r); | 1407 recorder->append (sample_l, sample_r); |
1400 } | 1408 } |
1401 } | 1409 } |
1402 else if (recorder->get_nbits () == 24) | 1410 else if (recorder->get_nbits () == 24) |
1403 { | 1411 { |
1420 sample_l32 |= 0xff000000; | 1428 sample_l32 |= 0xff000000; |
1421 | 1429 |
1422 if (sample_r32 & 0x00800000) | 1430 if (sample_r32 & 0x00800000) |
1423 sample_r32 |= 0xff000000; | 1431 sample_r32 |= 0xff000000; |
1424 | 1432 |
1425 recorder->append (sample_l32 / pow (2.0, 23), sample_r32 / pow (2.0, 23)); | 1433 recorder->append (sample_l32 / std::pow (2.0, 23), |
1434 sample_r32 / std::pow (2.0, 23)); | |
1426 } | 1435 } |
1427 } | 1436 } |
1428 | 1437 |
1429 if (recorder->get_sample_number () > recorder->get_end_sample ()) | 1438 if (recorder->get_sample_number () > recorder->get_end_sample ()) |
1430 return paComplete; | 1439 return paComplete; |