hasty compiler flags

This commit is contained in:
Dave Griffiths 2015-07-09 23:54:05 +01:00
parent 7d7c7c82f6
commit dcfd92721a
8 changed files with 27 additions and 12 deletions

View File

@ -13,8 +13,8 @@ SRCS := src/fft.cpp \
TARGET_SRCS := src/main.cpp
# for the minute, go out and up to link to the vision lib
CCFLAGS = @CFLAGS@ -std=c++11 -ffast-math -Wno-unused -Isrc
# @CFLAGS@
CCFLAGS = -Ofast -march=native -mtune=native -std=c++11 -ffast-math -Wno-unused -Isrc
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@

View File

@ -2036,6 +2036,7 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
ac_compiler_gnu=$ac_cv_c_compiler_gnu
: ${CXXFLAGS="-O3"}
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'

View File

@ -1,4 +1,5 @@
AC_INIT(samplebrain, version-0.1)
: ${CXXFLAGS="-O3"}
AC_PROG_CC
AC_CHECK_LIB(m, cos)

View File

@ -4,4 +4,4 @@ make distclean
autoheader
# build configure
autoconf configure.ac > configure
./configure CXX=g++-4.7 CCFLAGS=-O3
./configure 'CXX=g++-4.7' 'CXXFLAGS=-O3'

View File

@ -66,6 +66,8 @@ void block::init_fft(u32 block_size)
}
}
#define FFT_BIAS 200
double block::compare(const block &other, float ratio) const {
double mfcc_acc=0;
double fft_acc=0;
@ -74,7 +76,7 @@ double block::compare(const block &other, float ratio) const {
for (u32 i=0; i<m_fft.get_length(); ++i) {
fft_acc+=(m_fft[i]-other.m_fft[i]) * (m_fft[i]-other.m_fft[i]);
}
return fft_acc/(float)m_fft.get_length();
return (fft_acc/(float)m_fft.get_length())*FFT_BIAS;
}
if (ratio==1) {
@ -92,7 +94,7 @@ double block::compare(const block &other, float ratio) const {
mfcc_acc+=(m_mfcc[i]-other.m_mfcc[i]) * (m_mfcc[i]-other.m_mfcc[i]);
}
return (fft_acc/(float)m_fft.get_length())*(1-ratio) +
return (fft_acc/(float)m_fft.get_length())*(1-ratio)*FFT_BIAS +
(mfcc_acc/(float)MFCC_FILTERS)*ratio;
}

View File

@ -91,7 +91,7 @@ void brain::resynth(const string &filename, const brain &other, float ratio){
u32 pos = 0;
u32 count = 0;
cerr<<other.m_blocks.size()<<" brain blocks..."<<endl;
cerr<<endl;
for (vector<block>::iterator i=m_blocks.begin(); i!=m_blocks.end(); ++i) {
cerr<<'\r';
cerr<<"searching: "<<count/float(m_blocks.size())*100;

View File

@ -53,22 +53,27 @@ void run_audio(void* c, unsigned int frames) {
int main(int argc, char *argv[])
{
unit_test();
// unit_test();
cerr<<"starting"<<endl;
brain source, target;
// source.load_sound("../sound/source/shostakovich6.wav");
source.load_sound("../sound/source/808.wav");
source.load_sound("../sound/source/full.wav");
source.load_sound("../sound/source/joey.wav");
source.load_sound("../sound/source/pw2.wav");
source.load_sound("../sound/source/pw3.wav");
source.load_sound("../sound/source/claps.wav");
source.load_sound("../sound/source/eagle.wav");
// target.load_sound("../sound/source/sb-left.wav");
//target.load_sound("../sound/source/sb-left.wav");
target.load_sound("../sound/source/apache.wav");
cerr<<"loaded sounds"<<endl;
u32 len=1024;
cerr<<endl;
u32 len=3000;
source.init(len,len-len,50);
target.init(len,len-len/4,50);
target.init(len,len-len/8,50);
cerr<<"ready..."<<endl;
cerr<<"we have "<<source.get_num_blocks()<<" brain blocks ("<<source.get_num_blocks()*len/44100.0<<" secs)"<<endl<<endl;
a = new audio_device("samplebrain",44100,2048);

View File

@ -12,12 +12,18 @@ void renderer::init(brain &source, brain &target, float ratio) {
m_ratio = ratio;
}
static int ratio_time = 0;
void renderer::process(u32 nframes, float *buf) {
// get blocks from source for the current buffer
u32 tgt_shift = m_target.get_block_size()-m_target.get_overlap();
u32 tgt_start = m_render_time/(float)tgt_shift;
u32 tgt_end = (m_render_time+nframes)/(float)tgt_shift;
m_ratio = sin((ratio_time++)*0.01)*0.5+0.5;
cerr<<'\r';
cerr<<m_ratio;
if (tgt_end>=m_target.get_num_blocks()) {
m_render_time=0;
m_render_blocks.clear();