dhrebeniuk / RosaKit

LibRosa port to Swift for ability using same prepossessing logic in iOS/MacOS platforms
MIT License
87 stars 15 forks source link

Convert SampleRate to 22050 #2

Closed jeenezh closed 3 years ago

jeenezh commented 3 years ago

Hey, thanks a lot for sharing this great project. Just have a small question regarding the sample rate in the soundRecognize example. I saw you used CMSampleBuffer for capturing the audio data and the default sample rate is 44100, do you know if we can convert it into 22050? And out of curiosity, why do you not choose AVAudioEngine, is there any special concerns behind your choice? Thanks again and I really appreciate your help :)

dhrebeniuk commented 3 years ago

Hello @jeenezh , thanks for question. You can use AVAudioEngine and 22050.

I used AVSession, instead AVAudioEngine, because I have already work code with it and no time for reimplementing to AVAudioEngine.

jeenezh commented 3 years ago

Hey @dhrebeniuk, thanks so much for your quick reply! Okay, got it. If I wanna continue with your code AVSession and CMSamplebuffer, how can I convert sampleRate to 22050? Shall I change

private let kSampleBufferQueue = "com.cavap.SampleAudioBufferQueue"

Sorrie for spamming you, I checked out online but overwhelmed with many info. I am a master student and quite new to this field with sound analysis. Your code already helps me a lot. I cannot thank you enough.

dhrebeniuk commented 3 years ago

@jeenezh , are you wanna running code on iOS or MacOS?

jeenezh commented 3 years ago

In the iOS device

dhrebeniuk commented 3 years ago

@jeenezh , in such case need use AVAudioEngine.

jeenezh commented 3 years ago

Thanks a lot! Then I will try to implement AVAudioEngine.