reversound/src/processing/buffer/TemporalBuffer.java
gaugendre 6b4ec42c01 adding code
Switching from INSA svn to GitHub
2014-06-11 15:35:06 +02:00

65 lines
1.4 KiB
Java

package processing.buffer;
import generictools.Instant;
/**
* Created by gaby on 27/03/14.
*/
public class TemporalBuffer <T> extends Buffer<T> {
private int sampleRate = 0;
private Instant originInstant =Instant.fromTime(0);
/**
* Constructeur du buffer temporel
* @param arrayType type de stockage
* @param sampleRate fréquence d'échantillonage en Hz
*/
public TemporalBuffer(Storage.Type arrayType, int sampleRate) {
super(arrayType);
this.sampleRate = sampleRate;
}
public TemporalBuffer(Storage.Type arrayType, int sampleRate, Instant originInstant) {
this(arrayType, sampleRate);
this.originInstant = originInstant;
}
/**
* Renvoie la fréquence d'échantillonage
* @return Fréquence d'échatillonage en Hz
*/
public int getSampleRate() {
return sampleRate;
}
/**
* Renvoie la valeur de l'instant pour l'index 0
* @return Instant de l'origine des indexs
*/
public Instant getOriginInstant() {
return originInstant;
}
/**
* Renvoie la valeur de l'échantillon à un instant donné
* @param time Temps en ms
* @return Valeur de l'échantillon
*/
public T get(float time){
return get(Instant.fromTime(time).mapToIndex(this));
}
/**
* Renvoie la valeur de l'échantillon à un instant donné
* @param instant Instant
* @return Valeur de l'échantillon
*/
public T get(Instant instant){
return get(instant.mapToIndex(this));
}
}