Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
hashreds committed Dec 6, 2023
2 parents c64b27d + 1256c6a commit 3ef725c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
3 changes: 1 addition & 2 deletions app/src/main/java/cse/gradle/AudioRecorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public void startRecording(String fileName) {
@Override
public void run() {
try {
// System.out.println("Start recording");
// the format of the TargetDataLine
DataLine.Info dataLineInfo = new DataLine.Info(
TargetDataLine.class,
Expand All @@ -67,12 +66,12 @@ public void run() {
targetDataLine);

// the file that will contain the audio data
// File audioFile = new File("recording.wav");
File audioFile = new File(fileName);
AudioSystem.write(
audioInputStream,
AudioFileFormat.Type.WAVE,
audioFile);
audioInputStream.close();
} catch (Exception ex) {
ex.printStackTrace();
}
Expand Down
37 changes: 37 additions & 0 deletions app/src/main/java/cse/gradle/MockAudioRecorder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package cse.gradle;

import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import java.io.File;

public class MockAudioRecorder extends AudioRecorder {

private boolean isRecordingStarted = false;

@Override
public void startRecording(String fileName) {
if (!isRecordingStarted) {
isRecordingStarted = true;
// Simulate the start of recording without actual audio capture
simulateRecording(fileName);
}
}

@Override
public void stopRecording() {
if (isRecordingStarted) {
// Simulate the stop of recording without actual audio capture
isRecordingStarted = false;
}
}

// Simulate the recording process without actual audio capture
private void simulateRecording(String fileName) {
try {
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(new File(fileName));
audioInputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/cse/gradle/MockModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class MockModel extends Model {

public MockModel() {
// call the super constructor with the test server url
super(mockUrlString);
super(mockUrlString);
// hard code the user id to be the test user
this.userId = mockUserId;
}
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/cse/gradle/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
import java.net.URISyntaxException;

import java.io.*;
import java.net.*;
import java.util.*;
import org.json.*;

public class Model implements ModelSubject {
protected String userId;
Expand Down

0 comments on commit 3ef725c

Please sign in to comment.