All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.cogchar.audio.spectrogram.Spectrogram Maven / Gradle / Ivy

The newest version!
/*
 *  Copyright 2011 by The Cogchar Project (www.cogchar.org).
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package org.cogchar.audio.spectrogram;

import java.util.ArrayList;
import java.util.List;
import org.apache.commons.math3.complex.Complex;

/**
 *
 * @author Matthew Stevenson 
 */
public class Spectrogram {
	private int mySize;
    private int myTime;
	private double myNormalize;
	private final List myData;
    private int[][] myDataBuffer;
    int myBufferIndex;
    private boolean myStore;


	public Spectrogram(int size, int time, double volNormalize, boolean store){
        myStore = store;
		mySize = size;
        myTime = 1;
		myData = new ArrayList(1000);
        //myDataBuffer = new int[myTime][mySize][3];
        myDataBuffer = new int[mySize][3];
        myBufferIndex = 0;
		myNormalize = volNormalize;
	}

	public void addData(Complex[] data){
        for(int i=0; i= myDataBuffer.length){
            copyBuffer();
        }*/
	}

    /*private void copyBuffer(){
        for(int i=0; i getPixels(){
        if(myBufferIndex > 0){
            copyBuffer();
        }
        return myData;
    }*/

	public int[][] getPixels(int i){
        if(myStore){
            return myData.get(i);
        }else{
            return myDataBuffer;
        }

	}

    public int size(){
        return myData.size();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy