Skip to content

Instantly share code, notes, and snippets.

@sqbing
Created March 20, 2015 04:02
Show Gist options
  • Save sqbing/13e7fba7342f96d54dfe to your computer and use it in GitHub Desktop.
Save sqbing/13e7fba7342f96d54dfe to your computer and use it in GitHub Desktop.
aquila_mfcc_crash_report
➜ aquila lldb a.out /tmp/20.wav
(lldb) target create "a.out"
Current executable set to 'a.out' (x86_64).
(lldb) settings set -- target.run-args "/tmp/20.wav"
(lldb) r
Process 24809 launched: '/Users/sqbing/Dev/Test/aquila/a.out' (x86_64)
Loaded file /tmp/20.wav (16b)
samples: 960000
sample frequency: 48000
Samples per frame: 1200
Samples per overlap: 720
File devided into 1998 frames.
Frame #0
Frame #1
a.out(24809,0x7fff7c370300) malloc: *** error for object 0x102806008: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
Process 24809 stopped
* thread #1: tid = 0x138b65, 0x00007fff95926286 libsystem_kernel.dylib`__pthread_kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
frame #0: 0x00007fff95926286 libsystem_kernel.dylib`__pthread_kill + 10
libsystem_kernel.dylib`__pthread_kill + 10:
-> 0x7fff95926286: jae 0x7fff95926290 ; __pthread_kill + 20
0x7fff95926288: movq %rax, %rdi
0x7fff9592628b: jmp 0x7fff95921c53 ; cerror_nocancel
0x7fff95926290: retq
(lldb) bt
* thread #1: tid = 0x138b65, 0x00007fff95926286 libsystem_kernel.dylib`__pthread_kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
* frame #0: 0x00007fff95926286 libsystem_kernel.dylib`__pthread_kill + 10
frame #1: 0x00007fff9322242f libsystem_pthread.dylib`pthread_kill + 90
frame #2: 0x00007fff8ee2eb53 libsystem_c.dylib`abort + 129
frame #3: 0x00007fff94abae06 libsystem_malloc.dylib`szone_error + 625
frame #4: 0x00007fff94ab06b3 libsystem_malloc.dylib`small_malloc_from_free_list + 875
frame #5: 0x00007fff94aae3bc libsystem_malloc.dylib`szone_malloc_should_clear + 1449
frame #6: 0x00007fff94aad877 libsystem_malloc.dylib`malloc_zone_malloc + 71
frame #7: 0x00007fff94aac395 libsystem_malloc.dylib`malloc + 42
frame #8: 0x00007fff994bc43e libc++.1.dylib`operator new(unsigned long) + 30
frame #9: 0x000000010000e75a a.out`std::__1::vector<std::__1::complex<double>, std::__1::allocator<std::__1::complex<double> > >::allocate(unsigned long) + 154
frame #10: 0x000000010000e658 a.out`std::__1::vector<std::__1::complex<double>, std::__1::allocator<std::__1::complex<double> > >::vector<std::__1::complex<double>*>(std::__1::complex<double>*, std::__1::enable_if<(__is_forward_iterator<std::__1::complex<double>*>::value) && (is_constructible<std::__1::complex<double>, std::__1::iterator_traits<std::__1::complex<double>*>::reference>::value), std::__1::complex<double>*>::type) + 280
frame #11: 0x000000010000e535 a.out`std::__1::vector<std::__1::complex<double>, std::__1::allocator<std::__1::complex<double> > >::vector<std::__1::complex<double>*>(std::__1::complex<double>*, std::__1::enable_if<(__is_forward_iterator<std::__1::complex<double>*>::value) && (is_constructible<std::__1::complex<double>, std::__1::iterator_traits<std::__1::complex<double>*>::reference>::value), std::__1::complex<double>*>::type) + 37
frame #12: 0x000000010000e25c a.out`Aquila::OouraFft::fft(double const*) + 284
frame #13: 0x0000000100011daf a.out`Aquila::Mfcc::calculate(Aquila::SignalSource const&, unsigned long) + 127
frame #14: 0x0000000100001ac0 a.out`main + 1808
frame #15: 0x00007fff8e1325c9 libdyld.dylib`start + 1
frame #16: 0x00007fff8e1325c9 libdyld.dylib`start + 1
(lldb)
#include <iostream>
#include <aquila/source/WaveFile.h>
#include <aquila/tools/TextPlot.h>
#include <aquila/transform/Mfcc.h>
#include <aquila/source/Frame.h>
#include <aquila/source/FramesCollection.h>
#include <algorithm>
#include <cstdlib>
int main(int argc, const char *argv[])
{
if(argc < 2) {
std::cout<<"Filename not found."<<std::endl;
return -1;
}
Aquila::WaveFile wav(argv[1]);
std::cout<<"Loaded file "<<wav.getFilename()
<<" ("<<wav.getBitsPerSample()<<"b)"<<std::endl
<<" samples: "<<wav.getSamplesCount()<<std::endl
<<" sample frequency: "<<wav.getSampleFrequency()<<std::endl;
int samples_per_frame = wav.getSampleFrequency()/40;
int samples_per_overlap = samples_per_frame*3/5;
std::cout<<"Samples per frame: "<<samples_per_frame<<std::endl;
std::cout<<"Samples per overlap: "<<samples_per_overlap<<std::endl;
Aquila::FramesCollection frames(wav,
samples_per_frame,
samples_per_overlap);
std::cout<<"File devided into "<<frames.count()<<" frames."<<std::endl;
unsigned int i = 0;
for(auto it = frames.begin(); it != frames.end(); ++it, ++i){
std::cout<<"Frame #"<<i<<std::endl;
Aquila::Mfcc mfcc(it->getSamplesCount());
auto mfccValues = mfcc.calculate(*it);
std::cout<<"Frame #"<<i<<" mfcc coefficients: "<<std::endl;
std::copy(
std::begin(mfccValues),
std::end(mfccValues),
std::ostream_iterator<double>(std::cout, " "));
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment