SampleBuffers.java (2590B)
1 /* 2 * _______ _____ _____ _____ 3 * |__ __| | __ \ / ____| __ \ 4 * | | __ _ _ __ ___ ___ ___| | | | (___ | |__) | 5 * | |/ _` | '__/ __|/ _ \/ __| | | |\___ \| ___/ 6 * | | (_| | | \__ \ (_) \__ \ |__| |____) | | 7 * |_|\__,_|_| |___/\___/|___/_____/|_____/|_| 8 * 9 * ------------------------------------------------------------- 10 * 11 * TarsosDSP is developed by Joren Six at IPEM, University Ghent 12 * 13 * ------------------------------------------------------------- 14 * 15 * Info: http://0110.be/tag/TarsosDSP 16 * Github: https://github.com/JorenSix/TarsosDSP 17 * Releases: http://0110.be/releases/TarsosDSP/ 18 * 19 * TarsosDSP includes modified source code by various authors, 20 * for credits and info, see README. 21 * 22 */ 23 24 /****************************************************************************** 25 * 26 * libresample4j 27 * Copyright (c) 2009 Laszlo Systems, Inc. All Rights Reserved. 28 * 29 * libresample4j is a Java port of Dominic Mazzoni's libresample 0.1.3, 30 * which is in turn based on Julius Smith's Resample 1.7 library. 31 * http://www-ccrma.stanford.edu/~jos/resample/ 32 * 33 * License: LGPL -- see the file LICENSE.txt for more information 34 * 35 *****************************************************************************/ 36 package be.tarsos.dsp.resample; 37 38 /** 39 * Callback for producing and consuming samples. Enables on-the-fly conversion between sample types 40 * (signed 16-bit integers to floats, for example) and/or writing directly to an output stream. 41 */ 42 interface SampleBuffers { 43 /** 44 * @return number of input samples available 45 */ 46 47 int getInputBufferLength(); 48 49 /** 50 * @return number of samples the output buffer has room for 51 */ 52 int getOutputBufferLength(); 53 54 /** 55 * Copy <code>length</code> samples from the input buffer to the given array, starting at the given offset. 56 * Samples should be in the range -1.0f to 1.0f. 57 * 58 * @param array array to hold samples from the input buffer 59 * @param offset start writing samples here 60 * @param length write this many samples 61 */ 62 void produceInput(float[] array, int offset, int length); 63 64 /** 65 * Copy <code>length</code> samples from the given array to the output buffer, starting at the given offset. 66 * 67 * @param array array to read from 68 * @param offset start reading samples here 69 * @param length read this many samples 70 */ 71 void consumeOutput(float[] array, int offset, int length); 72 }