ipcMain.removeAllListeners('update-recorder');
ipcMain.on('update-recorder', updateRecorder);
-// utility function used by play func.
+// Split Buffer into an array of len-sized Buffers.
function bufSplit(buf: Buffer, len: number): Array<Buffer> {
let chunks = [];
let i = 0;
}
// play audio buffers.
-export function play(input: string): void {
+export function play(input: Buffer): void {
let i = 0;
- console.log(Buffer.from(input, encoding));
- // format buffers into half their size to account for writable highwaterMark.
- const audio = bufSplit(Buffer.from(input), 8192);
- console.log(audio);
+
+ const audio = bufSplit(input, 8192);
// call this fuction after last audio chunk has been written.
const callback = () => {
// TODO: clear portAudio writable buffer on write end.
}
+
write();
- // iterate through audio array and write buffers to portAudio writable.
+
+ // Iterate through audio array and write buffers to portAudio writable.
function write() {
let chunk: Buffer;
let ok = true;
let success = false;
let auth = false;
+
const authSession = async (_event, payload: string | UserCreds | null): Promise<string> => {
return new Promise((resolve, reject) => {
});
};
+// function parseHexString(str: string) {
+// var result = [];
+// while (str.length >= 8) {
+// result.push(parseInt(str.substring(0, 8), 16));
+
+// str = str.substring(8, str.length);
+// }
+
+// return result;
+// }
+
const receiveMessage = (message: string): void => {
while (!auth) {
return;
}
+ // Parse the message.
const parsed: RenderMessage = JSON.parse(message);
console.log('message received', parsed.content.text);
+
+ // If there is audio, play it.
if (parsed.content.audio) {
- console.log('audio received');
- play(parsed.content.audio);
+ const audioBytes = Buffer.from(parsed.content.audio, 'hex');
+ play(audioBytes);
}
+
backgroundMitt.emit('ipc-renderer', {
endpoint: 'render-message',
message: parsed
+<template>
+ Input Item Content
+</template>
+
+<script lang="ts">
+
+import { defineComponent, onMounted, ref, onUnmounted } from "vue";
+import { calcSideProximity, calcPosition } from "./helpers"
+
+export default defineComponent({
+
+
+});
+
+</script>
+
+<style lang="scss" scoped>
+
+</style>
\ No newline at end of file