Changeset 1102 for trunk/src/org/apollo/meldex/Transcriber.java
- Timestamp:
- 05/10/18 16:04:51 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/apollo/meldex/Transcriber.java
r315 r1102 4 4 import java.util.ArrayList; 5 5 6 @SuppressWarnings("unchecked") // code in java 1.47 6 public class Transcriber 8 7 { … … 255 254 { 256 255 // Pitch track the note 257 ArrayList pitchData = pitchTracker.process(data, length, sampleRate);256 ArrayList<PitchValue> pitchData = pitchTracker.process(data, length, sampleRate); 258 257 259 258 // Average the pitch data … … 265 264 266 265 267 private int averagePitchData(ArrayList pitchData)266 private int averagePitchData(ArrayList<PitchValue> pitchData) 268 267 { 269 268 // Loop through the pitch values... 270 269 int i = 0, k = 0; 271 270 while (i < (pitchData.size() - 1)) { 272 int startPos = ((PitchValue) pitchData.get(i)).position;273 double period = ((PitchValue) pitchData.get(i)).period;271 int startPos = pitchData.get(i).position; 272 double period = pitchData.get(i).period; 274 273 double averagePeriod = period; 275 double runningPeriod = ((PitchValue) pitchData.get(i+1)).position - startPos;274 double runningPeriod = pitchData.get(i+1).position - startPos; 276 275 double numPeriods = runningPeriod / period; 277 276 … … 280 279 while ((i+j) < (pitchData.size() - 1)) { 281 280 // Get the next pitch estimate 282 period = ((PitchValue) pitchData.get(i+j)).period;283 int position = ((PitchValue) pitchData.get(i+j)).position;281 period = pitchData.get(i+j).period; 282 int position = pitchData.get(i+j).position; 284 283 285 284 // Make sure that this period is covered by the average so far … … 289 288 290 289 // Stop if we have covered more than 20 msec 291 int nextPos = ((PitchValue) pitchData.get(i+j+1)).position;290 int nextPos = pitchData.get(i+j+1).position; 292 291 // if ((nextPos - startPos) >= 445) { // !! PURE-ROG !! 293 292 if ((nextPos - startPos) >= (sampleRate * 0.02)) { … … 315 314 316 315 317 private int calculateHistogram(ArrayList data, int length)316 private int calculateHistogram(ArrayList<PitchValue> data, int length) 318 317 { 319 318 // This probably shouldn't be a constant … … 328 327 // Calculate the histogram data 329 328 for (int i = 0; i < (length - 1); i++) { 330 double period = ((PitchValue) data.get(i)).period;331 double position = ((PitchValue) data.get(i)).position;332 double periodLength = ((PitchValue) data.get(i+1)).position - position;329 double period = data.get(i).period; 330 double position = data.get(i).position; 331 double periodLength = data.get(i+1).position - position; 333 332 334 333 // We only need to do this if the pitch does not equal zero
Note:
See TracChangeset
for help on using the changeset viewer.