Linear PCM 16 bit to 8 bit

Vanya

I am trying to adopt recording part of the Apple example entitled "SpeakHere" to my purposes. Everything seems to fine, but I need to add an option which actually offers 8 bit recording. This is according to the specification not allowed by any audio settings, so I need some kind of conversion from 16 bit. I think I need to place it in the callback function.

// ____________________________________________________________________________________
// AudioQueue callback function, called when an input buffers has been filled.
void AQRecorder::MyInputBufferHandler(  void *                              inUserData,
                                        AudioQueueRef                       inAQ,
                                        AudioQueueBufferRef                 inBuffer,
                                        const AudioTimeStamp *              inStartTime,
                                        UInt32                              inNumPackets,
                                        const AudioStreamPacketDescription* inPacketDesc)
{
    AQRecorder *aqr = (AQRecorder *)inUserData;
    try {
        if (inNumPackets > 0) {
            // write packets to file
            XThrowIfError(AudioFileWritePackets(aqr->mRecordFile, FALSE, inBuffer->mAudioDataByteSize,
                                             inPacketDesc, aqr->mRecordPacket, &inNumPackets, inBuffer->mAudioData),
                       "AudioFileWritePackets failed");
            aqr->mRecordPacket += inNumPackets;
        }

        // if we're not stopping, re-enqueue the buffe so that it gets filled again
        if (aqr->IsRunning())
            XThrowIfError(AudioQueueEnqueueBuffer(inAQ, inBuffer, 0, NULL), "AudioQueueEnqueueBuffer failed");
    } catch (CAXException e) {
        char buf[256];
        fprintf(stderr, "Error: %s (%s)\n", e.mOperation, e.FormatError(buf));
    }
}

but to be honest don't know how. Any idea will be appreciated.

Vanya

After quite of investigation and trying things, I have found out, that I do not need conversion, but just have to set different format flags.

mRecordFormat.mFormatFlags      = kLinearPCMFormatFlagIsBigEndian;
mRecordFormat.mBitsPerChannel   = 8;

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Converting 32bit PCM to 16bit PCM programmatically

From Dev

Android conver audio to 16-bit PCM

From Dev

Android conver audio to 16-bit PCM

From Dev

Signed 16-bit ALSA PCM data to U8 Conversion on Linux

From Dev

Signed 16-bit ALSA PCM data to U8 Conversion on Linux

From Dev

Convert audio to 8-bit signed PCM

From Dev

Char size 8 bit or 16 bit?

From Dev

Convert Uint8 (floating-point AUDIO_F32) to int16_t (16bit PCM)

From Dev

What is the format for a mono channel 16bit PCM

From Dev

How to play 16-bit pcm array programmatically

From Dev

How does OpenCV imread convert between 16 bit and 8 bit

From Dev

Adding two 16 bit numbers using 8 bit registers (Assembly)

From Dev

compare 8bit value against 16bit value

From Dev

How to convert 8bit sound to 16bit

From Dev

Cannot move 8 bit address to 16 bit register

From Dev

NumPy convert 8-bit to 16/32-bit image

From Dev

efficient way to convert 16 bit value to 8 bit value

From Dev

Having 8-bit and 16-bit views on the same data?

From Dev

GameBoy 16-bit load into 8-bit memory

From Dev

Android 8 bit to 16 bit representation for Negative Numbers

From Dev

efficient way to convert 16 bit value to 8 bit value

From Dev

Android 8 bit to 16 bit representation for Negative Numbers

From Dev

Arithmetic operations with 8 and 16 bit integers

From Dev

Spectrum analyzer for .raw 16bit linear files

From Dev

Capture 8kHz, 16-bit Linear Samples with 4 frames of 20ms audio in each RTP Packet

From Dev

Is it the address bus size or the data bus size that determines "8-bit , 16-bit ,32-bit ,64-bit " systems?

From Dev

Does "16bit integer PCM data" mean it's signed or unsigned?

From Dev

Generating a tone in iOS with 16 bit PCM, AudioEngine.connect() throws AUSetFormat: error -10868

From Dev

how to create a simple iir low pass filter with not round errors? (16 bit pcm data)

Related Related

  1. 1

    Converting 32bit PCM to 16bit PCM programmatically

  2. 2

    Android conver audio to 16-bit PCM

  3. 3

    Android conver audio to 16-bit PCM

  4. 4

    Signed 16-bit ALSA PCM data to U8 Conversion on Linux

  5. 5

    Signed 16-bit ALSA PCM data to U8 Conversion on Linux

  6. 6

    Convert audio to 8-bit signed PCM

  7. 7

    Char size 8 bit or 16 bit?

  8. 8

    Convert Uint8 (floating-point AUDIO_F32) to int16_t (16bit PCM)

  9. 9

    What is the format for a mono channel 16bit PCM

  10. 10

    How to play 16-bit pcm array programmatically

  11. 11

    How does OpenCV imread convert between 16 bit and 8 bit

  12. 12

    Adding two 16 bit numbers using 8 bit registers (Assembly)

  13. 13

    compare 8bit value against 16bit value

  14. 14

    How to convert 8bit sound to 16bit

  15. 15

    Cannot move 8 bit address to 16 bit register

  16. 16

    NumPy convert 8-bit to 16/32-bit image

  17. 17

    efficient way to convert 16 bit value to 8 bit value

  18. 18

    Having 8-bit and 16-bit views on the same data?

  19. 19

    GameBoy 16-bit load into 8-bit memory

  20. 20

    Android 8 bit to 16 bit representation for Negative Numbers

  21. 21

    efficient way to convert 16 bit value to 8 bit value

  22. 22

    Android 8 bit to 16 bit representation for Negative Numbers

  23. 23

    Arithmetic operations with 8 and 16 bit integers

  24. 24

    Spectrum analyzer for .raw 16bit linear files

  25. 25

    Capture 8kHz, 16-bit Linear Samples with 4 frames of 20ms audio in each RTP Packet

  26. 26

    Is it the address bus size or the data bus size that determines "8-bit , 16-bit ,32-bit ,64-bit " systems?

  27. 27

    Does "16bit integer PCM data" mean it's signed or unsigned?

  28. 28

    Generating a tone in iOS with 16 bit PCM, AudioEngine.connect() throws AUSetFormat: error -10868

  29. 29

    how to create a simple iir low pass filter with not round errors? (16 bit pcm data)

HotTag

Archive