Giter Site home page Giter Site logo

Comments (4)

derekli66 avatar derekli66 commented on May 13, 2024

Hi little-dandan,

I checked the OSStatus, -50. It's an audio parameter error.
See on OSStatus.com.

  1. Would you like to share your testing conditions when you run this demo code? I am also curious about when this error raises.

  2. Do you mean to check the OSStatus, -50 and log the error in the code ?

from learning-core-audio-swift-samplecode.

little-dandan avatar little-dandan commented on May 13, 2024

Thank you for your answer:
as i run your demo, the acquired audio file can not play. its duration is 00:00, you can try it (CH06_AudioConverter).
My Xcode version is: Version 11.3.1(11C504)
Thank you

from learning-core-audio-swift-samplecode.

derekli66 avatar derekli66 commented on May 13, 2024

The issue came from using the latest API AudioFileReadPacketData. In the original sample code which was written in C language, it used the old API AudioFileReadPackets which is fine to use zero value of outNumBytes. But, int the new API AudioFileReadPacketData , it is no longer using outNumBytes and uses ioNumBytes instead. That means we need to specified the correct size of out buffer in bytes.

New Implementation like below

var outByteCount: UInt32 = ioDataPacketCount.pointee * UInt32(audioConverterSettings.inputFilePacketMaxSize)
audioConverterSettings.sourceBuffer = calloc(1, Int(outByteCount))
var result = AudioFileReadPacketData(audioConverterSettings.inputFile!,
                                         true,
                                         &outByteCount,
                                         audioConverterSettings.inputFilePacketDescriptions,
                                         Int64(audioConverterSettings.inputFilePacketIndex),
                                         ioDataPacketCount,
                                         audioConverterSettings.sourceBuffer)

Please check the commit f5b4591

Thanks for @little-dandan to help correct this error.

from learning-core-audio-swift-samplecode.

little-dandan avatar little-dandan commented on May 13, 2024

Thank you:
But there are new problems. output file duration is very short.
You can open the compressed audio file, the sound content will play very fast, completely can not hear the content.

from learning-core-audio-swift-samplecode.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.