Git Product home page Git Product logo

Comments (5)

brian-armstrong avatar brian-armstrong commented on June 12, 2024 1

As I look at this again, I think you really just want a QuietReceiver. You're right that these things are private so you'll need to fork slightly, but it looks like the changes should be minimal. I'm not sure what you mean specifically by recompiling from source but you would need to run a slightly different version of the library.

I think the process is

  • Expose QuietReceiver and whatever else until compiler stops complaining.
  • Instantiate a QuietReceiver using the same config as the QMFrameReceiver and whatever sample rate you're capturing at (44100, 48000, etc). This number has to be the sample rate that your capturer runs at.
  • Feed your instance samples using consumeAudioFromSamples. It just wants an array of floats and the length of the array.
  • Call receive on the instance. This is nonblocking - if there's no decoded frame then you just get a nil back. You can feed a block of samples, then just keep receiving until nothing else comes out.

Feeding the decoder requires a bit of care. It wants floating-point, mono PCM. It has to match this exactly to work.

It looks like the tap block gives you something that will just spit out floating point samples (floatChannelData) so you should be set there. The length parameter you give to QuietReceiver should be the number of samples, not the length in bytes of the buffer e.g. it should be length of buffer/4. I think this is the same value as frameLength.

The one thing you have to be careful of is that if you're capturing in stereo, then the buffer you give to quiet needs to be mono (you'll probably have to copy to a new buffer to make this work). Just throw away one of the channels, don't mix/add them together since that will cause destructive interference.

Let me know if you have more questions, but I think that's the high level idea.

from quietmodemkit.

brian-armstrong avatar brian-armstrong commented on June 12, 2024

Hi @theronic

I'm actually reworking this library now to make it cleaner for Swift. I'm planning on making it a "1.0" release. I'll add it to my list to add this functionality.

For now, if you want to fork it for your own purposes, you basically want to expose the call to quiet_decoder_consume somehow. The loopback audio system is a test setup that mimics the real sound system, but it might be a good place to use for inspiration. I think it operates on QuietAudioConsumer protocol objects, which might be useful for what you want (this just wraps the call to quiet_decoder_consume).

You can feed this consume function blocks of whatever size is convenient for you. Just make sure that the samples are in floating point PCM format. The size parameter is the number of samples, not the size of the buffer e.g. num_samples, not num_samples * 4. You will also need to tweak the quiet_decoder_create constructor if your recording isn't in 44100 Hz sample rate.

Let me know if you have more questions. I will probably push out the new version in a few weeks, possibly about a month.

Cheers

from quietmodemkit.

theronic avatar theronic commented on June 12, 2024

I see that quiet_decoder_consume is called from consumeAudioFromSamples, which in turn is called from

[d->consumer consumeAudioFromSamples:mono withLength:d->bufferLength];

Could you show an example of how I would manually pass in the samples from my installTap call so that I don't have two processes consuming audio resources?

These implementations seem to be private. Will I need to recompile from source?

from quietmodemkit.

brian-armstrong avatar brian-armstrong commented on June 12, 2024

On second reading, it looks like floatChannelData only returns non-nil if you're capturing in float. If you're capturing in something else, you'll need to convert to float, but it's pretty easy. For 16-bit fixed just divide all the samples by SHRT_MAX. For 32-bit fixed, divide by INT_MAX.

from quietmodemkit.

NorthernCaptain avatar NorthernCaptain commented on June 12, 2024

Hi @brian-armstrong !
Is there any news on your new Swift-friendly library?
Thanks a lot.

from quietmodemkit.

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.