mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-10 16:38:39 +02:00
Add beeps
This commit is contained in:
parent
ce32f1704e
commit
6543b74b52
4 changed files with 58 additions and 7 deletions
|
@ -21,36 +21,85 @@
|
||||||
|
|
||||||
Recorder;
|
Recorder;
|
||||||
|
|
||||||
|
function log(message) {
|
||||||
|
print(APP_NAME + ": " + message);
|
||||||
|
}
|
||||||
|
|
||||||
Recorder = (function () {
|
Recorder = (function () {
|
||||||
var IDLE = 0,
|
var IDLE = 0,
|
||||||
COUNTING_DOWN = 1,
|
COUNTING_DOWN = 1,
|
||||||
RECORDING = 2,
|
RECORDING = 2,
|
||||||
recordingState = IDLE;
|
recordingState = IDLE,
|
||||||
|
|
||||||
|
countdownTimer,
|
||||||
|
countdownSeconds,
|
||||||
|
COUNTDOWN_SECONDS = 3,
|
||||||
|
|
||||||
|
tickSound,
|
||||||
|
startRecordingSound,
|
||||||
|
finishRecordingSound,
|
||||||
|
TICK_SOUND = "../system/assets/sounds/countdown-tick.wav",
|
||||||
|
START_RECORDING_SOUND = "../system/assets/sounds/start-recording.wav",
|
||||||
|
FINISH_RECORDING_SOUND = "../system/assets/sounds/finish-recording.wav",
|
||||||
|
START_RECORDING_SOUND_DURATION = 1200,
|
||||||
|
SOUND_VOLUME = 0.2;
|
||||||
|
|
||||||
|
function playSound(sound) {
|
||||||
|
Audio.playSound(sound, {
|
||||||
|
position: MyAvatar.position,
|
||||||
|
localOnly: true,
|
||||||
|
volume: SOUND_VOLUME
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function isRecording() {
|
function isRecording() {
|
||||||
return recordingState === COUNTING_DOWN || recordingState === RECORDING;
|
return recordingState === COUNTING_DOWN || recordingState === RECORDING;
|
||||||
}
|
}
|
||||||
|
|
||||||
function startRecording() {
|
function startRecording() {
|
||||||
|
|
||||||
if (recordingState !== IDLE) {
|
if (recordingState !== IDLE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
log("Start countdown");
|
||||||
|
countdownSeconds = COUNTDOWN_SECONDS;
|
||||||
|
playSound(tickSound);
|
||||||
|
countdownTimer = Script.setInterval(function () {
|
||||||
|
countdownSeconds -= 1;
|
||||||
|
if (countdownSeconds <= 0) {
|
||||||
|
Script.clearInterval(countdownTimer);
|
||||||
|
playSound(startRecordingSound);
|
||||||
|
log("Start recording");
|
||||||
|
Script.setTimeout(function () {
|
||||||
|
// Delay start so that start beep is not included in recorded sound.
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
}, START_RECORDING_SOUND_DURATION);
|
||||||
|
recordingState = RECORDING;
|
||||||
|
} else {
|
||||||
|
playSound(tickSound);
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
recordingState = COUNTING_DOWN;
|
recordingState = COUNTING_DOWN;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function cancelRecording() {
|
function cancelRecording() {
|
||||||
|
log("Cancel recording");
|
||||||
|
if (recordingState === COUNTING_DOWN) {
|
||||||
|
Script.clearInterval(countdownTimer);
|
||||||
|
} else {
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
|
}
|
||||||
recordingState = IDLE;
|
recordingState = IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
function finishRecording() {
|
function finishRecording() {
|
||||||
|
log("Finish recording");
|
||||||
|
playSound(finishRecordingSound);
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
|
@ -60,13 +109,15 @@
|
||||||
function stopRecording() {
|
function stopRecording() {
|
||||||
if (recordingState === COUNTING_DOWN) {
|
if (recordingState === COUNTING_DOWN) {
|
||||||
cancelRecording();
|
cancelRecording();
|
||||||
} else {
|
} else if (recordingState === RECORDING) {
|
||||||
finishRecording();
|
finishRecording();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
|
tickSound = SoundCache.getSound(Script.resolvePath(TICK_SOUND));
|
||||||
|
startRecordingSound = SoundCache.getSound(Script.resolvePath(START_RECORDING_SOUND));
|
||||||
|
finishRecordingSound = SoundCache.getSound(Script.resolvePath(FINISH_RECORDING_SOUND));
|
||||||
}
|
}
|
||||||
|
|
||||||
function tearDown() {
|
function tearDown() {
|
||||||
|
|
BIN
scripts/system/assets/sounds/countdown-tick.wav
Normal file
BIN
scripts/system/assets/sounds/countdown-tick.wav
Normal file
Binary file not shown.
BIN
scripts/system/assets/sounds/finish-recording.wav
Normal file
BIN
scripts/system/assets/sounds/finish-recording.wav
Normal file
Binary file not shown.
BIN
scripts/system/assets/sounds/start-recording.wav
Normal file
BIN
scripts/system/assets/sounds/start-recording.wav
Normal file
Binary file not shown.
Loading…
Reference in a new issue