Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can i use directly with lib FreeStreamer to process audio #41

Open
satishVekariya opened this issue Feb 18, 2020 · 7 comments
Open

can i use directly with lib FreeStreamer to process audio #41

satishVekariya opened this issue Feb 18, 2020 · 7 comments

Comments

@satishVekariya
Copy link

https://github.com/muhku/FreeStreamer
Actually i'm trying apply gain to particular frequency

@bartolsthoorn
Copy link
Owner

Hi, I also saw your email, but since others might have the same question, I will answer here.

Comparing FreeStreamer to Novocaine, I see that both use "kAudioFormatLinearPCM", so in FreeStreamer it seems you should use FSPCMAudioStreamDelegate. It sounds like you are doing that already though.

If you can access the raw samples as floats, it should work. Is there a specific error message you are getting?

@satishVekariya
Copy link
Author

satishVekariya commented Feb 24, 2020

What i try is:

lazy var hp:NVPeakingEQFilter = {
        let f = NVPeakingEQFilter.init(samplingRate: 44100)!
        f.q = 2
        f.centerFrequency = 16000
        f.g = 2
        return f
    }()
    func audioStream(_ audioStream: FSAudioStream!, samplesAvailable samples: UnsafeMutablePointer<AudioBufferList>!, frames: UInt32, description: AudioStreamPacketDescription) {
        let float: UnsafeMutablePointer<Float>? = samples.pointee.mBuffers.mData?.assumingMemoryBound(to: Float.self)

        hp.filterData(float, numFrames: frames, numChannels: samples.pointee.mBuffers.mNumberChannels)
    }

if i try above code without any lib modification, it's doing nothing.
if i try above code with little modification in FreeSteamer file: audio_stream.cpp, L:1715, i get one channel block and other channel produce noise only, there is no sound!!

modification -> https://github.com/canopas/FreeStreamer/tree/satish/eq

        const UInt32 nFrames = outputBufferList.mBuffers[0].mDataByteSize / THIS->m_dstFormat.mBytesPerFrame;
        if (THIS->m_delegate) {
            THIS->m_delegate->samplesAvailable(&outputBufferList, nFrames, description);
        }
        
        // This blocks until the queue has been able to consume the packets
        THIS->audioQueue()->handleAudioPackets(outputBufferList.mBuffers[0].mDataByteSize,
                                         outputBufferList.mNumberBuffers,
                                         outputBufferList.mBuffers[0].mData,
                                         &description);
        
//        const UInt32 nFrames = outputBufferList.mBuffers[0].mDataByteSize / THIS->m_dstFormat.mBytesPerFrame;
        
//        if (THIS->m_delegate) {
//            THIS->m_delegate->samplesAvailable(&outputBufferList, nFrames, description);
//        }

@satishVekariya
Copy link
Author

satishVekariya commented Feb 24, 2020

without lib modification i get error like:

LuxeRadio(13191,0x1172105c0) malloc: Incorrect checksum for freed object 0x7f9f4d97c000: probably modified after being freed.
Corrupt value: 0xffffffffffe76270
LuxeRadio(13191,0x1172105c0) malloc: *** set a breakpoint in malloc_error_break to debug

or

objc[13270]: Hash table corrupted. This is probably a memory error somewhere. (table at 0x110b7f808, buckets at 0x7fecbe9c3c00 (8192 bytes), 512 buckets, 252 entries, 67 tombstones, data 0xfffffffbffffffe6 0xfffffffbffffffe6 0xffff9fffffffffe6 0xffff9fffffffffe6)

@bartolsthoorn
Copy link
Owner

Thank you for sharing the details. I have never used Swift, so that part is difficult for me to follow, but I assume you are sure that the NVPeakingEQFilter is allocated properly and not freed in between buffers / in between hp.filterData calls.

It seems the FreeStreamer samples are in int16_t, did you check that? I found this example: https://github.com/muhku/FreeStreamer/blob/master/Additions/FSFrequencyDomainAnalyzer.m#L207 Here, similar vDSP calls are used as within NVDSP, so you could use it as a starting point instead, did you take a look at this code?

@satishVekariya
Copy link
Author

satishVekariya commented Feb 24, 2020

@iatnam-ios
Copy link

@satishVekariya Do you apply gain to FreeStreamer?

@satishVekariya
Copy link
Author

satishVekariya commented Oct 5, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants