comparison audioio/ClipMixer.cpp @ 307:6eb15c3aee0a tonioni

More toward using clip mixer
author Chris Cannam
date Tue, 07 Jan 2014 13:10:35 +0000
parents 9716c75499ef
children 289d65722123
comparison
equal deleted inserted replaced
306:64382d824bfe 307:6eb15c3aee0a
34 34
35 bool 35 bool
36 ClipMixer::loadClipData(QString path, float f0) 36 ClipMixer::loadClipData(QString path, float f0)
37 { 37 {
38 if (m_clipData) { 38 if (m_clipData) {
39 cerr << "ClipPlayer::loadClipData: Already have clip loaded" << endl; 39 cerr << "ClipMixer::loadClipData: Already have clip loaded" << endl;
40 return false; 40 return false;
41 } 41 }
42 42
43 SF_INFO info; 43 SF_INFO info;
44 SNDFILE *file; 44 SNDFILE *file;
47 size_t i; 47 size_t i;
48 48
49 info.format = 0; 49 info.format = 0;
50 file = sf_open(path.toLocal8Bit().data(), SFM_READ, &info); 50 file = sf_open(path.toLocal8Bit().data(), SFM_READ, &info);
51 if (!file) { 51 if (!file) {
52 cerr << "ClipPlayer::loadClipData: Failed to open file " 52 cerr << "ClipMixer::loadClipData: Failed to open file "
53 << path << ": " << sf_strerror(file) << endl; 53 << path << ": " << sf_strerror(file) << endl;
54 return false; 54 return false;
55 } 55 }
56 56
57 tmpFrames = (float *)malloc(info.frames * info.channels * sizeof(float)); 57 tmpFrames = (float *)malloc(info.frames * info.channels * sizeof(float));
58 if (!tmpFrames) { 58 if (!tmpFrames) {
59 cerr << "ClipPlayer::loadClipData: malloc(" << info.frames * info.channels * sizeof(float) << ") failed" << endl; 59 cerr << "ClipMixer::loadClipData: malloc(" << info.frames * info.channels * sizeof(float) << ") failed" << endl;
60 return false; 60 return false;
61 } 61 }
62 62
63 sf_readf_float(file, tmpFrames, info.frames); 63 sf_readf_float(file, tmpFrames, info.frames);
64 sf_close(file); 64 sf_close(file);
65 65
66 m_clipData = (float *)malloc(info.frames * sizeof(float)); 66 m_clipData = (float *)malloc(info.frames * sizeof(float));
67 if (!m_clipData) { 67 if (!m_clipData) {
68 cerr << "ClipPlayer::loadClipData: malloc(" << info.frames * sizeof(float) << ") failed" << endl; 68 cerr << "ClipMixer::loadClipData: malloc(" << info.frames * sizeof(float) << ") failed" << endl;
69 free(tmpFrames); 69 free(tmpFrames);
70 return false; 70 return false;
71 } 71 }
72 72
73 for (i = 0; i < info.frames; ++i) { 73 for (i = 0; i < info.frames; ++i) {
82 82
83 m_clipLength = info.frames; 83 m_clipLength = info.frames;
84 m_clipF0 = f0; 84 m_clipF0 = f0;
85 m_clipRate = info.samplerate; 85 m_clipRate = info.samplerate;
86 } 86 }
87
88 void
89 ClipMixer::mix(float **toBuffers,
90 std::vector<NoteStart> newNotes,
91 std::vector<NoteEnd> endingNotes)
92 {
93 //!!! do this!
94 }
95