Comments (4)
What I found is a couple of issues in OutputSignalTracker which prevent the pitch output. First, installTap() has no effect on audioEngine - one has to substitute with audioPlayer. Second, the delegate in the closure was always nil so self.delegate?.signalTracker() was never called. Here is my replacement code which should give you an idea how to get some readings. It goes in the start() method of OutputSignalTracker. One must import Pitchy too.
let factory = EstimationFactory()
let estimator = factory.create(.yin) // Choose pitch method here!
let queue = DispatchQueue(label: "BeethovenQueue", attributes: [])
self.audioPlayer.installTap(onBus: 0, bufferSize: self.bufferSize, format: nil) { (buffer, time) in
queue.async { [weak self] in
guard let `self` = self else { return }
do {
let transformedBuffer = try estimator.transformer.transform(buffer: buffer)
let frequency = try estimator.estimateFrequency(
sampleRate: Float(time.sampleRate),
buffer: transformedBuffer)
let pitch = try Pitch(frequency: Double(frequency))
print(time,pitch)
DispatchQueue.main.async { [weak self] in
guard let `self` = self else { return }
//self.delegate?.pitchEngine(self, didReceivePitch: pitch)
}
} catch {
DispatchQueue.main.async { [weak self] in
guard let `self` = self else { return }
//self.delegate?.pitchEngine(self, didReceiveError: error)
}
}
}
}
One would then start the tracking with:
let config = Config(
bufferSize: 4096,
estimationStrategy: .yin, // has no effect, has to be set in the estimator, see above
audioUrl: Bundle.main.url(forResource: "sound_file", withExtension: "wav")!
)
let pitchEngine = PitchEngine(config: config)
pitchEngine.start()
from beethoven.
Also, I have the same problem.
from beethoven.
Yeah, Can you give an example of how to analyze an audio file and get the Pitch
array or something?
And, how would I know the timing info (offset in milliseconds) of each Pitch
sample?
from beethoven.
@jhristov perfect. Yep i replaced the following line in OutputSignalTracker::start
audioEngine.outputNode.installTap(onBus: bus, bufferSize: bufferSize, format: nil)
With
audioPlayer.installTap(onBus: bus, bufferSize: bufferSize, format: nil)
and everything else works. Good work
from beethoven.
Related Issues (20)
- Example App Crashed HOT 2
- Beethoven crashes sometimes when stopping PitchEngine HOT 2
- compile error HOT 3
- tvOS target HOT 1
- Can not access in Objective C HOT 1
- Can't find the "Sources" directory for manual installation HOT 1
- Library crash in simulator HOT 1
- But beethoven is deaf HOT 3
- why not support Simulator ????
- Crash upon engine start HOT 5
- Target watchOS HOT 1
- Podfile incorrect swift version set? HOT 1
- Maintained?
- MacOS Target HOT 2
- use in Unity
- Getting result is too quick with multiple frequency why not getting correct frequency,
- Question: why is the AudioSession category 'playAndRecord', instead of just 'record' ?
- Adding package to XCode 13 causes "the manifest is missing a Swift tools version specification" error HOT 1
- Hang Risk with Beethoven > InputSignalTracker.swift > start() HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from beethoven.