Ignore:
Timestamp:
05/10/18 16:04:51 (6 years ago)
Author:
davidb
Message:

Reworking of the code-base to separate logic from graphics. This version of Expeditee now supports a JFX graphics as an alternative to SWING

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/apollo/meldex/Transcriber.java

    r315 r1102  
    44import java.util.ArrayList;
    55
    6 @SuppressWarnings("unchecked") // code in java 1.4
    76public class Transcriber
    87{
     
    255254    {
    256255        // Pitch track the note
    257         ArrayList pitchData = pitchTracker.process(data, length, sampleRate);
     256        ArrayList<PitchValue> pitchData = pitchTracker.process(data, length, sampleRate);
    258257
    259258        // Average the pitch data
     
    265264
    266265
    267     private int averagePitchData(ArrayList pitchData)
     266    private int averagePitchData(ArrayList<PitchValue> pitchData)
    268267    {
    269268        // Loop through the pitch values...
    270269        int i = 0, k = 0;
    271270        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;
    274273            double averagePeriod = period;
    275             double runningPeriod = ((PitchValue) pitchData.get(i+1)).position - startPos;
     274            double runningPeriod = pitchData.get(i+1).position - startPos;
    276275            double numPeriods = runningPeriod / period;
    277276
     
    280279            while ((i+j) < (pitchData.size() - 1)) {
    281280                // 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;
    284283
    285284                // Make sure that this period is covered by the average so far
     
    289288
    290289                // 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;
    292291                // if ((nextPos - startPos) >= 445) {  // !! PURE-ROG !!
    293292                if ((nextPos - startPos) >= (sampleRate * 0.02)) {
     
    315314
    316315
    317     private int calculateHistogram(ArrayList data, int length)
     316    private int calculateHistogram(ArrayList<PitchValue> data, int length)
    318317    {
    319318        // This probably shouldn't be a constant
     
    328327        // Calculate the histogram data
    329328        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;
    333332
    334333            // We only need to do this if the pitch does not equal zero
Note: See TracChangeset for help on using the changeset viewer.