• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Issues for loading an array of data into a stream buffer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Issues for loading an array of data into a stream buffer


  • Subject: Re: Issues for loading an array of data into a stream buffer
  • From: David Lecoutre <email@hidden>
  • Date: Mon, 3 Aug 2009 19:52:45 -0500

Do you think that I don't play the floats correctly ? If you look at the DefaultOutputUnit sample, I made those changes in the RenderSin function.

void RenderSin (UInt32                 startingFrameCount,
                UInt32                 inFrames,
                void*                inBuffer,
                double                 inSampleRate,
                double                 amplitude,
                double                 frequency,
                int                    inOutputFormat,
                Float32*    _mysoundbuffer,
                UInt32 SizeBuffer)
{
    for (UInt32 frame = 0; frame < (inFrames); ++frame)
    {
        if((theLastPosition+frame)<SizeBuffer){
                 Float32 nextFloat = _mysoundbuffer[(theLastPosition+frame)];
                static_cast<Float32*>(inBuffer)[frame] = nextFloat;
        }else{
              // go back to the beginning of the buffer
            theLastPosition=0;
        }
    }

        theLastPosition+=inFrames;
}

This is how I'm initializing my AudioStream :

    AudioStreamBasicDescription streamFormat;
    streamFormat.mSampleRate = 44100;        //    the sample rate of the audio stream
    streamFormat.mFormatID = kAudioFormatLinearPCM;            //    the specific encoding type of audio stream
I am not sure if this is the right formatID...

    streamFormat.mFormatFlags = kAudioFormatFlagsNativeFloatPacked
                                |
kAudioFormatFlagIsNonInterleaved;        //    flags specific to each format

    streamFormat.mBytesPerPacket = 2;   
    streamFormat.mFramesPerPacket = 1;   
    streamFormat.mBytesPerFrame = 2;       
    streamFormat.mChannelsPerFrame = 1;   
    streamFormat.mBitsPerChannel = 16;   
With those settings I don't get any sound when I'm trying to play the floats ( I've filled the buffer of floats with a wav file, the values are between -100 and 100 ). It seems that I'm doing something wrong but I didn't figure out what...

Thanks,
David L-

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Issues for loading an array of data into a stream buffer
      • From: Jeff Moore <email@hidden>
References: 
 >Issues for loading an array of data into a stream buffer (From: David Lecoutre <email@hidden>)
 >Re: Issues for loading an array of data into a stream buffer (From: William Stewart <email@hidden>)

  • Prev by Date: Re: Echo cancellation and audio codec in coreaudio
  • Next by Date: Re: Issues for loading an array of data into a stream buffer
  • Previous by thread: Re: Issues for loading an array of data into a stream buffer
  • Next by thread: Re: Issues for loading an array of data into a stream buffer
  • Index(es):
    • Date
    • Thread