Mercurial > hg > aimc
comparison src/Modules/Input/ModuleFileInput.cc @ 150:9425901c60a6
corrected a bug with stereo files in FileInput, and some more stuff
author | hamel.phil |
---|---|
date | Thu, 06 Jan 2011 03:33:11 +0000 |
parents | f8ace1ee8782 |
children | 45ab8d4613ad |
comparison
equal
deleted
inserted
replaced
149:a61f41b221e1 | 150:9425901c60a6 |
---|---|
101 vector<float> buffer; | 101 vector<float> buffer; |
102 buffer.resize(buffer_length_ * audio_channels_); | 102 buffer.resize(buffer_length_ * audio_channels_); |
103 | 103 |
104 // Read buffersize bytes into buffer | 104 // Read buffersize bytes into buffer |
105 read = sf_readf_float(file_handle_, &buffer[0], buffer_length_); | 105 read = sf_readf_float(file_handle_, &buffer[0], buffer_length_); |
106 | 106 for (int i = 0; i < 10; i++) { |
107 LOG_INFO(_T("%i: %f, %f"),i,buffer[2*i],buffer[2*i+1]); | |
108 } | |
107 // Place the contents of the buffer into the signal bank | 109 // Place the contents of the buffer into the signal bank |
108 int counter = 0; | 110 int counter = 0; |
109 for (int c = 0; c < audio_channels_; ++c) { | 111 for (int i = 0; i < read; ++i) { |
110 for (int i = 0; i < read; ++i) { | 112 for (int c = 0; c < audio_channels_; ++c) { |
111 output_.set_sample(c, i, buffer[counter]); | 113 output_.set_sample(c, i, buffer[counter]); |
112 ++counter; | 114 ++counter; |
113 } | 115 } |
114 } | 116 } |
115 | 117 |
116 // If the number of samples read is less than the buffer length, the end | 118 // If the number of samples read is less than the buffer length, the end |
117 // of the file has been reached. | 119 // of the file has been reached. |
118 if (read < buffer_length_) { | 120 if (read < buffer_length_) { |
119 // Zero samples at end | 121 // Zero samples at end |
120 for (int c = 0; c < audio_channels_; ++c) { | 122 for (int i = read; i < buffer_length_; ++i) { |
121 for (int i = read; i < buffer_length_; ++i) { | 123 for (int c = 0; c < audio_channels_; ++c) { |
122 output_.set_sample(c, i, 0.0f); | 124 output_.set_sample(c, i, 0.0f); |
123 } | 125 } |
124 } | 126 } |
125 // When we're past the end of the buffer, set the | 127 // When we're past the end of the buffer, set the |
126 // module state to 'done' and exit. | 128 // module state to 'done' and exit. |