/** * Main method * * @param args * ignored */ public static void main(String[] args) { // The data: final double[] data1 = new double[] { -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; // The chart generator final BarVisualisation bv = new BarVisualisation(1000, 400); // set the data bv.setData(data1); // show the result bv.showWindow("Data"); } }
/** * Shows a basic bar visualisation. * * @param args * The bar visualisation. */ public static void main(final String[] args) { final int nPoints = 10; final double[] data = new double[nPoints]; for (int i = 0; i < nPoints; i++) data[i] = nPoints * (Math.random() * 2 - 1); final BarVisualisation bv = new BarVisualisation(1000, 600); bv.setDrawValues(true); bv.setData(data); bv.setTransformer(new LabelTransformer() { @Override public String transform(final double value) { return String.format("%2.2f", value); } }); bv.showWindow("Bar Visualisation Demo"); } }
final BarVisualisation bv = new BarVisualisation(1500, 500); bv.setDrawValues(true); bv.fixAxis( 250 ); bv.showWindow("MFCCs"); while ((sc = a.nextSampleChunk()) != null) bv.getVisualisationImage().zero(); final double[][] mfccs = mfcc.calculateMFCC(sc.getSampleBuffer()); bv.setData( Arrays.copyOfRange( mfccs[0], 1, mfccs[0].length ) );
final BarVisualisation bv = new BarVisualisation( 400, 200 ); bv.setAxisLocation( 100 ); bv.setMaxValue( 0.0001 ); bv.showWindow( "SpectralFlux" ); bv.setData( flux[0] );
final BarVisualisation bv = new BarVisualisation( 400, 200 ); bv.setMaxValue( 1E12 ); bv.setAutoScale( false ); bv.showWindow( "FFTs" ); bv.setData( ffts[0] );
final BarVisualisation bv = new BarVisualisation(400, 200); bv.showWindow("FFTs"); bv.getAxesRenderer().setDrawYTicks(false); bv.setData(ffts[0]);
/** * Creates the given visualisation with the given data * * @param width * The width of the image * @param height * The height of the image * @param data * The data to visualise */ public BarVisualisation(final int width, final int height, final double[] data) { this(width, height); this.setData(data); }
/** * Set the data to a double array * * @param data * The data */ public void setData(final double[] data) { super.data.clear(); if (this.useFixedBarWidth) for (int i = 0; i < data.length; i++) super.data.add(new LocatedObject<Bar>(i, data[i], new Bar(data[i], i, i + this.barWidth, RGBColour.RED))); else for (int i = 0; i < data.length; i++) super.data.add(new LocatedObject<Bar>(i, data[i], new Bar(data[i], i, i + this.barWidth, RGBColour.RED))); super.validateData(); this.axesRenderer2D.setMaxXValue(data.length); // Force the axis to be zero if the axis always visible flag is set if (axisAlwaysVisible) if (getMinValue() > 0) setMinValue(0); else if (getMaxValue() < 0) setMaxValue(0); super.updateVis(); }
final BarVisualisation bv = new BarVisualisation(1500, 500); bv.setDrawValues(true); bv.fixAxis( 250 ); bv.showWindow("MFCCs"); while ((sc = a.nextSampleChunk()) != null) bv.getVisualisationImage().zero(); final double[][] mfccs = mfcc.calculateMFCC(sc.getSampleBuffer()); bv.setData( Arrays.copyOfRange( mfccs[0], 1, mfccs[0].length ) );
final BarVisualisation bv = new BarVisualisation( 400, 200 ); bv.setAxisLocation( 100 ); bv.showWindow( "MFCCs" ); bv.setData( mfccs[0] );
/** * Set the data from a long array. * * @param data * The data to set */ public void setData(final long[] data) { this.setData(ArrayUtils.convertToDouble(data)); }
/** * Main method * @param args Command-line args (unused) * @throws MalformedURLException Will not be thrown */ public static void main( final String[] args ) throws MalformedURLException { // Open a URL to the sine wave sweep. If you have downloaded // this file you should use a new File(<filename>) here. final XuggleAudio xa = new XuggleAudio( new URL( "http://www.audiocheck.net/download.php?" + "filename=Audio/audiocheck.net_sweep20-20klin.wav" ) ); // Create the Fourier transform processor chained to the audio decoder final MFCC mfcc = new MFCC( xa ); // Create a visualisation to show our FFT and open the window now final BarVisualisation bv = new BarVisualisation( 400, 200 ); bv.showWindow( "MFCCs" ); // Loop through the sample chunks from the audio capture thread // sending each one through the feature extractor and displaying // the results in the visualisation. while( mfcc.nextSampleChunk() != null ) { final double[][] mfccs = mfcc.getLastCalculatedFeatureWithoutFirst(); bv.setData( mfccs[0] ); } } }
/** * Set the data from a float array. * * @param data * The data to set */ public void setData(final float[] data) { this.setData(ArrayUtils.convertToDouble(data)); }
final BarVisualisation bv = new BarVisualisation( 1500, 400 ); bv.setData( lastFFT[0] ); bv.showWindow( "FFT" );
final BarVisualisation bv = new BarVisualisation( 1500, 400 ); bv.setData( lastFFT[0] ); bv.showWindow( "FFT" );