I am trying to use fftTap from iOS microphone with AudioKit, and here is the code
fft = FFTTap(highPassFilter2!, bufferSize: 8192 * 4, fftValidBinCount: nil, handler: {data in})
I tried using a bufferSize of 8192 * 4, which has allowed me to detect HZ at intervals of about 1.3
(Sample Rate is 44100, 44100 / (8192 * 4) = 1.34582519531, am I correct ?)
but I always get the exception error in File BaseTap around line 90.
private func handleTapBlock(buffer: AVAudioPCMBuffer, at time: AVAudioTime) {
// Call on the main thread so the client doesn't have to worry
// about thread safety.
buffer.frameLength = bufferSize <<<<< here
The log shows
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: length <= _imp->_frameCapacity'
terminating with uncaught exception of type NSException
It seems not work, but I want to be able to capture the accuracy less than 2 Hz, is there any way to try?
Really Thanks.
Related
if I define property as String.
#Property NSString * value;
Terminating app due to uncaught exception 'RLMException', reason:
'Invalid value '1993654' of type '__NSCFNumber' for 'string?'
Or if define as integer.
#Property NSInteger value;
Terminating app due to uncaught exception 'RLMException', reason:
'Invalid value '1973906' of type 'NSTaggedPointerString' for 'int'
in both cases app crashed.
Crash Report.
*** Terminating app due to uncaught exception 'RLMException', reason: 'Invalid value '1973906' of type 'NSTaggedPointerString' for 'int?' property 'MMCase.Id'.'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff23b98bde __exceptionPreprocess + 350
1 libobjc.A.dylib 0x00007fff503b5b20 objc_exception_throw + 48
2 Realm 0x000000010ad75659 _Z17RLMThrowTypeErrorP11objc_objectP15RLMObjectSchemaP11RLMProperty + 617
3 Realm 0x000000010ad766bb _Z27RLMValidateValueForPropertyP11objc_objectP15RLMObjectSchemaP11RLMPropertyb + 3659
4 Realm 0x000000010ab63576 _ZN18RLMAccessorContext18value_for_propertyEP11objc_objectRKN5realm8PropertyEm + 214
5 Realm 0x000000010abd70af _ZN5realm6Object6createIU8__strongP11objc_object18RLMAccessorContextEES0_RT0_RKNSt3__110shared_ptrINS_5RealmEEERKNS_12ObjectSchemaET_bbmPNS_8BasicRowINS_5TableEEE + 431
6 Realm 0x000000010abd8595 RLMCreateObjectInRealmWithValue + 1477
7 Realm 0x000000010ab62c18 _ZN18RLMAccessorContext5unboxIN5realm12BasicRowExprINS1_5TableEEEEET_P11objc_objectbbbm + 296
8 Realm 0x000000010ab745cd _ZN5realm12_GLOBAL__N_112ValueUpdaterIU8__strongP11objc_object18RLMAccessorContextEclEPNS_12BasicRowExprINS_5TableEEE + 157
9 Realm 0x000000010ab735ef
You should try with NSNumber *value; instead. This is pointed out in the first exception you posted __NSCFNumber. From there you can use either
[value stringValue];
or
[value intValue];
To create it, you can use paradigm:
value = [NSNumber numberWithInt: intValue];
fixed by using NSNumber instead of NSIntger.
use
#property NSNumber<RLMInt> *value
instead of
#Property NSInteger value;
Depends on type.
I've got crash with this code
// ViewController.swift
import UIKit
import AVFoundation
class ViewController: UIViewController {
var engine:AVAudioEngine!
var EQNode:AVAudioUnitEQ!
override func viewDidLoad() {
engine.reset()
let Format = engine.inputNode.outputFormat(forBus: 0)
print("channelcount:",engine.inputNode.inputFormat(forBus: 0).channelCount)
//----->Start CRASH App stoped here
engine.connect(engine.inputNode, to: EQNode, format: Format)
engine.connect(EQNode, to: engine.mainMixerNode, format: Format)
var error: NSError?
engine.prepare()
print("done prepare")
do {
try engine.start()
} catch {
print(error)
}
print("done start")
}
}
And if I change Format to nil it make my app not working but not crash.
All of this work perfectly fine on Xcode simulator with no error.
But in the real iOS device (I use iPad 2019) test it crash.
Detail about my app: Live microphone adjust in Equalizer and display Equalized sound real-time.
ERROR:
SelfhearEQ[3532:760180] [aurioc] AURemoteIO.cpp:1086:Initialize: failed: -10851
(enable 1, outf< 2 ch, 0 Hz, Float32, non-inter> inf< 1 ch, 44100 Hz, Float32>)
channelcount: 0
2019-10-22 18:01:29.891748+0700 SelfhearEQ[3532:760180] [aurioc] AURemoteIO.cpp:1086:Initialize: failed: -10851
(enable 1, outf< 2 ch, 0 Hz, Float32, non-inter> inf< 1 ch, 44100 Hz, Float32>)
2019-10-22 18:01:29.892326+0700 SelfhearEQ[3532:760180] [avae]
AVAEInternal.h:76 required condition is false: [AVAudioEngineGraph.mm:2127:_Connect: (IsFormatSampleRateAndChannelCountValid(format))]
2019-10-22 18:01:29.896270+0700 SelfhearEQ[3532:760180] *** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: IsFormatSampleRateAndChannelCountValid(format)'
I found the answer for this it nothing about formatting causing this error.
Check it out on my other question it fixed.
avaudioengine-connect-crash-on-hardware-not-simulator
I have an irregular crash (1 in 5 times on devices, 4 in 5 times on Simulator). I have set an exception breakpoint and it occurs on the following line without any console information:
if let carColorSet = car.carToDisplay?.allObjects as? [Display] {
Note: car.carToDisplay is an NSSet
Before I set the exception breakpoint, I would get the following info in the console when it crashed:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSMutableSet unionSet:]: set argument is not an NSSet'
*** First throw call stack:
(
0 CoreFoundation 0x0000000102e79b0b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00000001023d6141 objc_exception_throw + 48
2 CoreFoundation 0x0000000102e00051 -[NSMutableSet unionSet:] + 1041
3 CoreData 0x0000000101b10df8 -[_NSFaultingMutableSet willReadWithContents:] + 936
4 CoreData 0x0000000101af131b -[_NSFaultingMutableSet allObjects] + 27
5 Keyboard 0x00000001018f838e
Any idea here? It seems like the crash occurs when I try to turn that carToDisplay?.allObjects into an array of Display objects.
This is a keyboard extension app btw.
Thank you for any input!
Problem (probably):
if let carColorSet = car.carToDisplay?.allObjects as? [Display]
carToDisplay is a NSet
However the function allObjects returns an array
I think you are trying to do a unionSet with an array.
Update the Question:
Please update your question, the qestion doesn't state the correct line of error.
The question needs to do the following
state where the unionSet is invoked.
what the argument type of unionSet is.
This question already has an answer here:
Timestamp function that has been working reliably just caused EXC_BAD_INSTRUCTION
(1 answer)
Closed 5 years ago.
My code, which use SimplePing:
func simplePing(_ pinger: SimplePing, didSendPacket packet: Data, sequenceNumber: UInt16) {
begin[String(sequenceNumber)] = Int(Date().timeIntervalSince1970 * 1000)//AppDelegate.swift:185
print("Send: \(Common.startCount)")
}
It works perfectly in my simulator and iPhone, but after made it available on AppStore, I received about 20 crash logs with some error like that:
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x00000000e7ffdefe
Triggered by Thread: 1
...
Thread 1 name:
Thread 1 Crashed:
0 ME 0x0011e5cc specialized AppDelegate.simplePing(SimplePing, didSendPacket : Data, sequenceNumber : UInt16) -> () + 652 (AppDelegate.swift:185)
1 ME 0x00116990 #objc AppDelegate.simplePing(SimplePing, didSendPacket : Data, sequenceNumber : UInt16) -> () + 68
2 ME 0x00116818 #objc AppDelegate.simplePing(SimplePing, didSendPacket : Data, sequenceNumber : UInt16) -> () + 40
3 ME 0x000f3348 -[SimplePing sendPingWithData:] + 640 (SimplePing.m:297)
...
I can't reproduce that crash, so I have to analysis that line of the code:
begin[String(sequenceNumber)]
begin initialized with begin = [String: Int](), so its type is [String : Int], and sequenceNumber's type is UInt16. So I think begin[String(sequenceNumber)] doesn't have any potential bug.
Int(Date().timeIntervalSince1970 * 1000)
And Int(Date().timeIntervalSince1970 * 1000) is just something like Int(aDouble * 1000), it seems correct in any situation.
So I get really confused with that crash log, could anyone please give me some hints?
From the docs for Int:
On 32-bit platforms, Int is the same size as Int32, and on 64-bit platforms, Int is the same size as Int64.
A signed 32-bit integer has a maximum value of 2,147,483,647.
At the moment, Int(Date().timeIntervalSince1970 * 1000) returns a value of 1,495,855,170,970.
That is significantly larger than what will fit in a 32-bit integer.
The crash is being caused by the overflow you are attempting when casting the Double to an Int when run on a 32-bit iOS device.
I would suggest an explicit use of Int64 instead of Int:
begin[String(sequenceNumber)] = Int64(Date().timeIntervalSince1970 * 1000)
I am seeing odd behavior with CGRectIntegral. This is my code:
CGRect rect = CGRectMake(75, 22, 235, 48.000000000000007);
rect = CGRectIntegral(rect);
NSAssert1(rect.size.height == 49, #"I expected 49, but I got: %f!", rect.size.height);
// works on 32 bit iPhone simulator
// throws an exception on iPhone 64 bit simulator & iPhone 5s:
// Terminating app due to uncaught exception 'NSInternalInconsistencyException',
// reason: 'I expected 49, but I got: 48.000000!'
My guess is, that it has something to do with CGFloat being a float on 32Bit and a double on 64Bit – and with the presumed use of the ceil within CGRectIntegral.
Is it a bug in Apple's code?
How can I fix this....elegantly?