Code Monkey home page Code Monkey logo

Comments (3)

bauglir avatar bauglir commented on September 25, 2024

From libsndfile's FAQ it appears that it doesn't actually do any interleaving/deinterleaving automatically. So my guess is that the problem has to do with the implementation of Base.read for AudioFiles. This currently returns arr[1:nread]. Now for stereo files this is a 2 x n_frames array. Since Julia reads through arrays in column-major order, every sample from the stereo file is 'repeated', which results in stereo files playing back at half speed (or something along those lines).

Returning arr[:, 1:nread] instead should solve this. I have implemented this in #20. I've tested a stereo file and it was mixed down properly into a single channel playing at regular speed. Since playing files was broken for me I wasn't able to check the behavior you describe here.

A point for discussion is given that Julia uses column-major order, should AudioIO perhaps use this to its advantage by representing audio data in n_frames x n_channels arrays instead of in n_channel x n_frames. The upside is that this would (theoretically) improve performance when working in Julia. The downside being that the latter is the convention for most C libraries AudioIO interfaces with, so any function interfacing with those should take care of proper conversion.

from audioio.jl.

bauglir avatar bauglir commented on September 25, 2024

Looking a bit more into the code. I think most of AudioIO already expects audio data to be in this format when dealing with stereo audio. So I've added a commit to #20 that makes sure audio data is read from a file as n_frames x n_channels.

from audioio.jl.

ssfrr avatar ssfrr commented on September 25, 2024

#20 fixes this, thanks!

from audioio.jl.

Related Issues (20)

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.