From 13cf7d41707f9c999604baf89448047a4553aec1 Mon Sep 17 00:00:00 2001 From: Andrew Gundersen Date: Fri, 5 Mar 2021 10:41:43 -0600 Subject: [PATCH 1/4] better comments --- crash.log | 2 ++ src/components/content.vue | 0 src/components/helpers.ts | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 src/components/content.vue diff --git a/crash.log b/crash.log index 3d7e5c0..14b4301 100644 --- a/crash.log +++ b/crash.log @@ -43,3 +43,5 @@ PID 60328 received SIGSEGV for address: 0x7f900fab4000 12 libsystem_pthread.dylib 0x00007fff205f747b thread_start + 15 PID 65740 received SIGSEGV for address: 0x7fbddef00000 0 segfault-handler.node 0x0000000116e6ae60 _ZL16segfault_handleriP9__siginfoPv + 304 +PID 65817 received SIGSEGV for address: 0x7fe23f39d000 +0 segfault-handler.node 0x0000000110840e60 _ZL16segfault_handleriP9__siginfoPv + 304 diff --git a/src/components/content.vue b/src/components/content.vue new file mode 100644 index 0000000..e69de29 diff --git a/src/components/helpers.ts b/src/components/helpers.ts index ec57775..658802a 100644 --- a/src/components/helpers.ts +++ b/src/components/helpers.ts @@ -15,12 +15,12 @@ export function calcSideProximity (inputItemX: number, winW: number) { export function calcPosition (inputItemPosition: number, percent: number, short: number, win: number) { - // Is it close to the right/left side? + // Is it close to a side? If so, stay fixed. if (percent > 0.75) { inputItemPosition = win - short } - // Is it not close to a side? + // Else move relativly. if (percent < 0.75 && percent > 0.25) { inputItemPosition = win * percent } From e8bb64e56a9e1d497039fadcb1d2d3971b21fa9b Mon Sep 17 00:00:00 2001 From: Andrew Gundersen Date: Sat, 6 Mar 2021 10:53:04 -0600 Subject: [PATCH 2/4] audio playback --- src/background/audio.ts | 14 +++++++------- src/background/session.ts | 20 ++++++++++++++++++-- src/components/content.vue | 19 +++++++++++++++++++ 3 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/background/audio.ts b/src/background/audio.ts index 313f6f1..f267177 100644 --- a/src/background/audio.ts +++ b/src/background/audio.ts @@ -33,7 +33,7 @@ const updateRecorder = (_event, payload: boolean): void => { 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 { let chunks = []; let i = 0; @@ -75,19 +75,19 @@ export function initAudioIO(): void { } // 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; diff --git a/src/background/session.ts b/src/background/session.ts index bd42b34..75f9433 100644 --- a/src/background/session.ts +++ b/src/background/session.ts @@ -32,6 +32,7 @@ let socket: WebSocket; let success = false; let auth = false; + const authSession = async (_event, payload: string | UserCreds | null): Promise => { return new Promise((resolve, reject) => { @@ -60,6 +61,17 @@ const authSession = async (_event, payload: string | UserCreds | null): Promise< }); }; +// 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) { @@ -67,12 +79,16 @@ const receiveMessage = (message: string): void => { 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 diff --git a/src/components/content.vue b/src/components/content.vue index e69de29..e623548 100644 --- a/src/components/content.vue +++ b/src/components/content.vue @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file From 90dff9769e4e936e234870a71570aef68cd6d29d Mon Sep 17 00:00:00 2001 From: Andrew Gundersen Date: Sat, 6 Mar 2021 10:53:33 -0600 Subject: [PATCH 3/4] audio --- src/background/audio.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/background/audio.ts b/src/background/audio.ts index f267177..98e2909 100644 --- a/src/background/audio.ts +++ b/src/background/audio.ts @@ -35,7 +35,7 @@ ipcMain.on('update-recorder', updateRecorder); // Split Buffer into an array of len-sized Buffers. function bufSplit(buf: Buffer, len: number): Array { - let chunks = []; + const chunks = []; let i = 0; let L = len; From 311ce05a30a35409f019a72efab3c5228bcfa835 Mon Sep 17 00:00:00 2001 From: Andrew Gundersen Date: Sun, 7 Mar 2021 13:50:09 -0600 Subject: [PATCH 4/4] appear animation v1 --- src/components/inputItem.vue | 7 +++- src/components/messageItem.vue | 18 ++++++++++ src/test.vue | 66 ---------------------------------- src/views/messenger.vue | 10 ++++-- 4 files changed, 32 insertions(+), 69 deletions(-) delete mode 100644 src/test.vue diff --git a/src/components/inputItem.vue b/src/components/inputItem.vue index 13c7303..444c74d 100644 --- a/src/components/inputItem.vue +++ b/src/components/inputItem.vue @@ -1,10 +1,15 @@ \ No newline at end of file diff --git a/src/test.vue b/src/test.vue deleted file mode 100644 index 5651d69..0000000 --- a/src/test.vue +++ /dev/null @@ -1,66 +0,0 @@ - // Snap to the nearest window border and update percentages. Called when - // user stops dragging the inputItem. - const mouseUp = (e: any) => { - window.removeEventListener('mousemove', divMove, true); - - const winW = window.innerWidth - const winH = window.innerHeight - console.log(`Window dimensions: W${winW} H${winH}`) - - // First, are we changing inputItemX or inputItemY? - - let xShort = winW - inputItemX.value - if (xShort > winW / 2) { - xShort = inputItemX.value - } - - let yShort = winH - inputItemY.value - if (yShort > winH / 2) { - yShort = inputItemY.value - } - - const shortest = (xShort < yShort) ? "inputItemX" : "inputItemY" - - // Then, are we tranlating it positive or negative? - // To answer this, we see which side is it closer to. - // We also update percentages to aid in window resizing (handleResize). - - if (shortest == "inputItemX") { - if (inputItemX.value < winW / 2) { - inputItemX.value = 0 - percentX = 0.0 - } else { - inputItemX.value = winW - 38 - percentX = 1.0 - } - percentY = inputItemY.value / winH - } else { - if (inputItemY.value < winH / 2) { - inputItemY.value = 0 - percentY = 0.0 - } else { - inputItemY.value = winH - 38 - percentY = 1.0 - } - percentX = inputItemX.value / winW - - } - console.log(`Percents updated: iX: ${percentX} iY: ${percentY}`) - } - - - - - if (percentX == 1.0) { - inputItemX.value = window.innerWidth * percentX - 38 - } else { - inputItemX.value = window.innerWidth * percentX - } - - if (percentY == 1.0) { - inputItemY.value = window.innerHeight * percentY - 38 - } else { - inputItemY.value = window.innerHeight * percentY - } - - } \ No newline at end of file diff --git a/src/views/messenger.vue b/src/views/messenger.vue index e765719..d0631e4 100644 --- a/src/views/messenger.vue +++ b/src/views/messenger.vue @@ -32,11 +32,18 @@ export default defineComponent({ // List of messages in the view. // Oldest message first. const messages: Message[] = reactive([]); + const messages_ref: any = {} // Render a message. + // Called on "enter" instead of on "recv message" const render = (message: Message) => { messages.push(message); - console.log(`Pushing: ${message.modifier}: ${message.content.text} ${message.context}`); + messages_ref[message.id] = message; + } + + // Annotate/update an existing message. + const annotate = (message: Message) => { + 1+1 } onMounted(() => { @@ -68,7 +75,6 @@ export default defineComponent({ position: fixed; width: 100vw; - min-height: 100vh; overflow-y: scroll;