Giter Club home page Giter Club logo

Comments (5)

erikd avatar erikd commented on June 18, 2024

What overloads for src_short_to_float_array and why?

from libsamplerate.

Flamefire avatar Flamefire commented on June 18, 2024

Have 1 function each for converting from/to float to allow for more generic user code:

std::vector<short> doConvert(std::vector<short> data){
  std::vector<float> floats(data.size());
  to_float_array(data.data(), data.size(), floats.data());
  // Work with floats
  from_float_array(floats.data(), floats.size(), data.data());
  return data;
}

The overloads allow to change the type of parameter data to e.g. std::vector<int> without touching the rest of the code.

This gets more powerful the more conversion functions exist (see e.g. #72)

from libsamplerate.

erikd avatar erikd commented on June 18, 2024

You have not even read (or maybe misunderstood) the documentation for those auxiliary functions. I actually regret having ever added them to this library, because having them encourages suggestions like this one.

This library does sample rate conversion. It should not do anything else.

This gets more powerful the more conversion functions exist (see e.g. #72)

Audio data stored 8 bit has a dynamic range of 42db which is about nowhere near adequate fidelity for professional audio purposes and significantly less that even extremely primitive audio compression algorithms like u-law and A-law. As far as I am concerned providing conversion functions to convert to and from that format is waste of time unless it is to provide the ability to read legacy file formats (for which you would use libsndfile).

from libsamplerate.

Flamefire avatar Flamefire commented on June 18, 2024

You have not even read (or maybe misunderstood) the documentation for those auxiliary functions.

Then I'm missing your point. What exactly do you mean? The linked docu states There are <n> auxillary functions for converting arrays of float data to and from <other types> data. [...] [values are] automatically scaled [...] values which would overflow [...] are clipped. (shortened to be slightly more general and show how I read it)

This library does sample rate conversion. It should not do anything else.

Ok sure, understand this. Then cut those overloads from this issue. The C++ wrapper would still be a nice addition to have RAII provided by the library.

to read legacy file formats (for which you would use libsndfile).

Just a note: That legacy format is not readable by libsndfile. We still need the conversion to float without round-tripping via a WAV file (create WAV header, write to file, load with libsndfile, convert, optionally store) Having the conversions of raw data in a library would avoid having to reimplement (and test) it in user code and this looked like the place to do that (see above note about how I understood the docu).

from libsamplerate.

erikd avatar erikd commented on June 18, 2024

The scaling mentioned in that documentation is correct for short but unlikely to be correct for any type which is not short.

As for your legacy format, it makes far more sense to add support for it to libsndfile than it does adding the conversion functions here.

from libsamplerate.

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.