// Path: dev/java/vocobox-api/src/main/java/org/vocobox/model/note/Voyel.java
// public enum Voyel {
//     A, E, I, O, OU, U;
//     
//     public static Voyel parse(String voyel){
//         for(Voyel v: Voyel.values()){
//             if(v.toString().equals(voyel.toUpperCase())){
//                 return v;
//             }
//         }
//         System.out.println("did not parse " + voyel);
//         return null;
//         //throw new IllegalArgumentException("not a voyel : " + voyel + ". Try among " + Voyel.values());
//     }
// }


import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.sound.sampled.UnsupportedAudioFileException;
import org.jzy3d.chart.Chart;
import org.vocobox.io.datasets.HumanVoiceDataset;
import org.vocobox.model.note.MAPSNote;
import org.vocobox.model.note.Note;
import org.vocobox.model.note.NoteDescriptor;
import org.vocobox.model.note.NoteDescriptors;
import org.vocobox.model.note.Voyel;
package org.vocobox.apps.benchmark.charts;




public class NoteMozaic {

    public static Chart[][] oneNote(String name, float expected, float semitoneDistance) throws Exception {
        Note note = HumanVoiceDataset.NOTES.getNote(name);
        Chart[][] charts = new Chart[2][1];
        charts[0][0] = chartFrequency(note);
        charts[0][1] = chartEval(note, semitoneDistance);
        return charts;
    }

    public static Chart[][] evalChartsPitch(Note[][] notes, int startAt, float semitoneError) throws Exception {
        int octaves = notes.length;
        int semitones = notes[0].length;
        Chart[][] charts = new Chart[(octaves - startAt) * 2][semitones];

        for (int octave = startAt; octave < octaves; octave++) {
            for (int tone = 0; tone < notes[octave].length; tone++) {
                Note note = notes[octave][tone];
                if (note != null) {
                    charts[octave - startAt][tone] = chartFrequency(note);
                    charts[octave - startAt + octaves][tone] = chartEval(note, semitoneError);
                }
            }
        }
        return charts;
    }

    /* */

    public static Chart[][] evalChartsVoyels(List<Note> voyels) throws Exception {
        return evalChartsVoyels(getVoyelMatrix(voyels));
    }

    public static Chart[][] evalChartsVoyels(Note[][] voyels) throws Exception {
        Chart[][] charts = new Chart[2][voyels.length];
        for (int tone = 0; tone < voyels.length; tone++) {
            Note note = voyels[tone][0];
            if (note != null) {
                charts[0][tone] = chartFrequency(note);
                charts[1][tone] = chartEval(note, 0.5f);
            }
        }

        return charts;
    }
    

    public static Chart[][] evalChartsVoyelInstances(Note[][] voyels) throws Exception {
        Chart[][] charts = new Chart[voyels.length][voyels[0].length*2];
        
        for (int i = 0; i < voyels.length; i++) {
            for (int j = 0; j < voyels[i].length; j++) {
                Note note = voyels[i][j];
                if(note!=null){
                    charts[i][j] = chartFrequency(note);
                    charts[i][j+voyels[0].length] = chartEval(note, 0.5f);
                    
                }
            }
        }
        return charts;
    }

    public static Note[][] getVoyelMatrix(List<Note> notes) {
// Path: dev/java/vocobox-api/src/main/java/org/vocobox/model/note/Voyel.java
// public enum Voyel {
//     A, E, I, O, OU, U;
//     
//     public static Voyel parse(String voyel){
//         for(Voyel v: Voyel.values()){
//             if(v.toString().equals(voyel.toUpperCase())){
//                 return v;
//             }
//         }
//         System.out.println("did not parse " + voyel);
//         return null;
//         //throw new IllegalArgumentException("not a voyel : " + voyel + ". Try among " + Voyel.values());
//     }
// }


// Path: dev/java/vocobox-apps/src/main/java/org/vocobox/apps/benchmark/charts/NoteMozaic.java
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.sound.sampled.UnsupportedAudioFileException;
import org.jzy3d.chart.Chart;
import org.vocobox.io.datasets.HumanVoiceDataset;
import org.vocobox.model.note.MAPSNote;
import org.vocobox.model.note.Note;
import org.vocobox.model.note.NoteDescriptor;
import org.vocobox.model.note.NoteDescriptors;
import org.vocobox.model.note.Voyel;

package org.vocobox.apps.benchmark.charts;




public class NoteMozaic {

    public static Chart[][] oneNote(String name, float expected, float semitoneDistance) throws Exception {
        Note note = HumanVoiceDataset.NOTES.getNote(name);
        Chart[][] charts = new Chart[2][1];
        charts[0][0] = chartFrequency(note);
        charts[0][1] = chartEval(note, semitoneDistance);
        return charts;
    }

    public static Chart[][] evalChartsPitch(Note[][] notes, int startAt, float semitoneError) throws Exception {
        int octaves = notes.length;
        int semitones = notes[0].length;
        Chart[][] charts = new Chart[(octaves - startAt) * 2][semitones];

        for (int octave = startAt; octave < octaves; octave++) {
            for (int tone = 0; tone < notes[octave].length; tone++) {
                Note note = notes[octave][tone];
                if (note != null) {
                    charts[octave - startAt][tone] = chartFrequency(note);
                    charts[octave - startAt + octaves][tone] = chartEval(note, semitoneError);
                }
            }
        }
        return charts;
    }

    /* */

    public static Chart[][] evalChartsVoyels(List<Note> voyels) throws Exception {
        return evalChartsVoyels(getVoyelMatrix(voyels));
    }

    public static Chart[][] evalChartsVoyels(Note[][] voyels) throws Exception {
        Chart[][] charts = new Chart[2][voyels.length];
        for (int tone = 0; tone < voyels.length; tone++) {
            Note note = voyels[tone][0];
            if (note != null) {
                charts[0][tone] = chartFrequency(note);
                charts[1][tone] = chartEval(note, 0.5f);
            }
        }

        return charts;
    }
    

    public static Chart[][] evalChartsVoyelInstances(Note[][] voyels) throws Exception {
        Chart[][] charts = new Chart[voyels.length][voyels[0].length*2];
        
        for (int i = 0; i < voyels.length; i++) {
            for (int j = 0; j < voyels[i].length; j++) {
                Note note = voyels[i][j];
                if(note!=null){
                    charts[i][j] = chartFrequency(note);
                    charts[i][j+voyels[0].length] = chartEval(note, 0.5f);
                    
                }
            }
        }
        return charts;
    }

    public static Note[][] getVoyelMatrix(List<Note> notes) {
        Note[][] matrix = new Note[Voyel.values().length][1];