Commit b33e4a2d authored by CallisteHanriat's avatar CallisteHanriat

changing sampleRate : force it to become 16khz even if the selected file is at 8khz

parent e2a9c3a3
......@@ -39,6 +39,7 @@ public class Microphone {
* @throws MicException If the microphone couldn't be set up.
*/
public Microphone(long sampleRate) throws MicException {
sampleRate = 16000l;
physicalMicrophone = getListener(
(int) sampleRate,
AudioFormat.ENCODING_PCM_16BIT,
......
......@@ -58,6 +58,7 @@ public class PhoneRespeaker implements
/** Sets up the microphone for recording. */
private void setUpMicrophone(long sampleRate) throws MicException {
Log.d("Rte-PhoneRespeak", "sampleRate : " + sampleRate);
this.microphone = new Microphone(sampleRate);
}
......
......@@ -149,6 +149,7 @@ public class Recorder implements AudioHandler, MicrophoneListener, Sampler {
/** Sets up the micrphone for recording */
private void setUpMicrophone(long sampleRate) throws MicException {
Log.d("Rte-Recorder", "samrate: " + sampleRate);
this.sampleRate = sampleRate;
this.microphone = new Microphone(sampleRate);
}
......
......@@ -43,6 +43,7 @@ public class ThumbRespeaker {
*/
public ThumbRespeaker(Recording original, UUID respeakingUUID,
int rewindAmount) throws MicException, IOException {
Log.d("Rte-ThumbRespeaker", "smp : " + original.getSampleRate());
recorder = new Recorder(1, new File(Recording.getNoSyncRecordingsPath(),
respeakingUUID + ".wav"), original.getSampleRate());
player = new SimplePlayer(original, true);
......
......@@ -8,6 +8,8 @@ import android.os.Environment;
import android.os.Parcel;
import android.util.Log;
import org.lp20.aikuma.Aikuma;
import org.lp20.aikuma.audio.SegmentPlayer;
import org.lp20.aikuma.ui.RecordActivityLig;
import org.lp20.aikuma.util.FileIO;
import org.lp20.aikuma.util.IdUtils;
import org.lp20.aikuma.util.StandardDateFormat;
......@@ -500,7 +502,7 @@ public class Recording extends FileModel {
encodedRecording.put("speakers", speakersIdsArray);
encodedRecording.put("device", deviceName);
encodedRecording.put("androidID", this.androidID);
encodedRecording.put("sampleRate", getSampleRate());
encodedRecording.put(RecordActivityLig.intent_sampleRate, getSampleRate());
encodedRecording.put("durationMsec", getDurationMsec());
encodedRecording.put("item_id", this.groupId);
encodedRecording.put("suffix", this.respeakingId);
......@@ -769,10 +771,10 @@ public class Recording extends FileModel {
}
long sampleRate;
if (jsonObj.get("sampleRate") == null) {
if (jsonObj.get(RecordActivityLig.intent_sampleRate) == null) {
sampleRate = -1;
} else {
sampleRate = (Long) jsonObj.get("sampleRate");
sampleRate = (Long) jsonObj.get(RecordActivityLig.intent_sampleRate);
}
int durationMsec;
......@@ -1245,6 +1247,7 @@ public class Recording extends FileModel {
private void setSampleRate(long sampleRate) {
this.sampleRate = sampleRate;
Log.d("Recording", "setSampleRate : " +sampleRate);
}
private void setRespeakingId(String respeakingId) {
......
......@@ -162,6 +162,10 @@ public class RecordingLig extends Recording {
Log.i(TAG, "mapping file " + mapFile.getAbsolutePath() + " moves to " + destFile.getAbsolutePath());
}
/**
* called when we want to save wav and json file into recording folder.
*/
public void write() throws IOException {
// Ensure the directory exists
File dir = getIndividualRecordingPath();
......
......@@ -83,7 +83,7 @@ public class RespeakingMetadataLig extends AikumaActivity implements OnClickList
metaJSON = FileIO.readJSONObject(new File(FileIO.getOwnerPath(),
RecordingLig.RECORDINGS + OrigDirName
+ "/" + origRecName + RecordingLig.METADATA_SUFFIX));
recordSampleRate = (Long) metaJSON.get("sampleRate");
recordSampleRate = 16000l;
// JSONObject metaJSON = FileIO.readJSONObject(new File(recordPath.split(".")[0]
// + RecordingLig.METADATA_SUFFIX));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment