thanks. too much to ask for an "error: mformatFlag is wrong Endian" haha
On Thu, Jan 14, 2016 at 11:23 PM Paul Davis <[email protected]> wrote: > RIFF/WAV is a little-endian format. > > On Thu, Jan 14, 2016 at 11:16 PM, Alexander Bollbach < > [email protected]> wrote: > >> thanks for the response. I will consider a convenience function. When >> you write convenience functions such as one like that, do you use it across >> multiple projects? If so, do you do anything to facilitate that? Just >> create a .c,.h and import the headers wherever? just curious. So I was >> finally able to get the audio file to write the data. I played back the >> file in finder and heard my voice sound checking and it was glorious. >> >> I got it to work by changing the file type enum to CAF. I guess that my >> ASBD was not compatible with a wav file format although i'm not certain >> about that. Here was what I was using with wav and am now successfully >> passing in as the inStreamDesc when creating the ExtAudioFile. >> >> // asbd for audiofile >> AudioStreamBasicDescription fmt; >> fmt.mSampleRate = 44100.0; >> fmt.mFormatID = kAudioFormatLinearPCM; >> fmt.mFormatFlags = kAudioFormatFlagIsBigEndian | >> kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked; >> fmt.mBytesPerPacket = 4; >> fmt.mFramesPerPacket = 1; >> fmt.mBytesPerFrame = 4; >> fmt.mChannelsPerFrame = 2; >> >> My guess is that there is something in this that isn't compatible with >> the wav file formatting structure. Still, it'd be nice not to have to >> construct this at all. Passing in a reference to the audio stream that I >> have in my struct (which comes from the audio unit) also results in a fmt? >> error. That stream is obtained like so: >> >> >> // set sample rate between input and output scopes equal and assign >> stream to player struct >> >> propertySize = sizeof (AudioStreamBasicDescription); >> >> CheckError(AudioUnitGetProperty(player->inputUnit, >> >> kAudioUnitProperty_StreamFormat, >> >> kAudioUnitScope_Output, >> >> inputBus, >> >> &player->streamFormat, >> >> &propertySize), "Couldn't get ASBD >> from input unit"); >> >> >> >> AudioStreamBasicDescription deviceFormat; >> >> CheckError(AudioUnitGetProperty(player->inputUnit, >> >> kAudioUnitProperty_StreamFormat, >> >> kAudioUnitScope_Input, >> >> inputBus, >> >> &deviceFormat, >> >> &propertySize), "Couldn't get ASBD >> from input unit"); >> >> >> >> player->streamFormat.mSampleRate = deviceFormat.mSampleRate; >> >> >> >> propertySize = sizeof (AudioStreamBasicDescription); >> >> CheckError(AudioUnitSetProperty(player->inputUnit, >> >> kAudioUnitProperty_StreamFormat, >> >> kAudioUnitScope_Output, >> >> inputBus, >> >> &player->streamFormat, >> >> propertySize), "Couldn't set ASBD on >> input unit"); >> >> I'm sure there is something in that as well that is not capable with the >> wav format. Anyway, CAF files are suitable for now. I would still like to >> know why WAV was such an issue. >> >> >> >> fmt.mBitsPerChannel = 16; >> >> On Thu, Jan 14, 2016 at 9:53 PM Christian Rober <[email protected]> >> wrote: >> >>> Alexander, >>> >>> Let's definitely try to resolve that error first... If you are getting >>> that error from ExtAudioFileCreateWithURL then my guess is that the ASBD >>> you are passing in does not match the enum type you are also passing in. >>> In other words, if you pass kAudioFileWAVEType to the create function, >>> then your ASBD should probably look something like this: >>> >>> { >>> >>> AudioStreamBasicDescription streamDescription = {0}; >>> >>> Float64 sampleRate = 44100; >>> >>> int channels = 2; // Do you want Stereo? >>> >>> streamDescription.mSampleRate = sampleRate; >>> >>> streamDescription.mFormatID = kAudioFormatLinearPCM; >>> >>> streamDescription.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | >>> kAudioFormatFlagIsPacked; >>> >>> streamDescription.mBytesPerPacket = 4; >>> >>> streamDescription.mFramesPerPacket = 1; >>> >>> streamDescription.mBytesPerFrame = 4; >>> >>> streamDescription.mChannelsPerFrame = channels; >>> >>> streamDescription.mBitsPerChannel = 16; >>> >>> } >>> >>> That is just one way to do it (bordering on too manual IMO). I thought >>> there were handy MACROS for this in the SDK but maybe I am conflating that >>> with something else... >>> >>> Minor related suggestion: consider creating this ASBD as a return value >>> from a static function, it may be handy in the future... it was for me. >>> >>> Lastly, and just for completeness: In terms of the client property, it >>> should probably match the audio buffers you intend to pass into the >>> WriteAsync functions and not necessarily the format of the WAV file >>> itself. In your snippet you seem to be re-using the ASBD, which may not >>> always apply. >>> >>> --Christian >>> On Thu, Jan 14, 2016 at 7:43 PM, Alexander Bollbach < >>> [email protected]> wrote: >>> >>>> Thank you for the help. >>>> >>>> Fokke, I have since changed the way i set the stream for my audio >>>> file. You can that in this gist >>>> <https://gist.github.com/AlexanderBollbach/3b862db17adf240928f8>. >>>> >>>> Christian, I have tried setting that property but since doing that I am >>>> now unable to create the audiofile. In fact that might have been the >>>> problem to begin with as I was not checking the OSStatus of >>>> >>>> ExtAudioFileCreateWithURL. I now see that I get a 'fmt?' .. but if >>>> you take a look at that Gist I have no idea what could be the reason. In >>>> the convenience function CreateInputUnit I get the stream off the audio >>>> unit and set it as a member var in my struct. This is what I use to >>>> instantiate the ext audiofile but it doesn't seem to like the stream/'fmt'. >>>> >>>> On Thu, Jan 14, 2016 at 3:19 PM Fokke de Jong <[email protected]> >>>> wrote: >>>> >>>>> HI Alexander, >>>>> >>>>> I just answered you on stack exchange, it think there is something >>>>> wrong with your stream description. There might be more, but you should >>>>> check that first. >>>>> >>>>> best, >>>>> Fokke >>>>> >>>>> >>>>> On Jan 14, 2016, at 17:31 , Alexander Bollbach < >>>>> [email protected]> wrote: >>>>> >>>>> no one? >>>>> >>>>> On Wed, Jan 13, 2016 at 5:47 PM Alexander Bollbach < >>>>> [email protected]> wrote: >>>>> >>>>>> I am still unable to write audio samples from my AUHAL's input >>>>>> callback to a file. I have tried a number of things including using the >>>>>> asynchronous version of writing to an audio file in ExtAudioFileServices. >>>>>> Even wrapping the call in a dispatch queue in fear that it was going out >>>>>> of >>>>>> scope. Even though it is probably some small obvious thing that is >>>>>> missing >>>>>> (i'm only a few months into using core audio) I posted a stack >>>>>> question >>>>>> <http://stackoverflow.com/questions/34714832/writing-bytes-to-audio-file-using-auhal-audio-unit> >>>>>> about >>>>>> it. Apparently other uses have gotten the (-50) error. That is indeed >>>>>> the error I get. (you can run the GitHub Repo >>>>>> <https://github.com/AlexanderBollbach/AUHAL_Recorder> in xcode to >>>>>> verify this). I've been casually trying to get this to work over the >>>>>> past >>>>>> few days and I'm not getting any results. Any idea what I might be doing >>>>>> wrong? >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> _______________________________________________ >>>>> Do not post admin requests to the list. They will be ignored. >>>>> Coreaudio-api mailing list ([email protected]) >>>>> Help/Unsubscribe/Update your Subscription: >>>>> >>>>> >>>>> https://lists.apple.com/mailman/options/coreaudio-api/fokkedejong%40gmail.com >>>>> >>>>> This email sent to [email protected] >>>>> >>>>> >>>>> >>>> _______________________________________________ >>>> Do not post admin requests to the list. They will be ignored. >>>> Coreaudio-api mailing list ([email protected]) >>>> Help/Unsubscribe/Update your Subscription: >>>> >>> >>>> https://lists.apple.com/mailman/options/coreaudio-api/recapitch%40gmail.com >>>> >>>> This email sent to [email protected] >>>> >>> >> _______________________________________________ >> Do not post admin requests to the list. They will be ignored. >> Coreaudio-api mailing list ([email protected]) >> Help/Unsubscribe/Update your Subscription: >> > >> https://lists.apple.com/mailman/options/coreaudio-api/paul%40linuxaudiosystems.com >> >> This email sent to [email protected] >> > >
_______________________________________________ Do not post admin requests to the list. They will be ignored. Coreaudio-api mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/coreaudio-api/archive%40mail-archive.com This email sent to [email protected]
