Skip to content

Commit

Permalink
first prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
agolvet committed Mar 29, 2024
1 parent 6a0a740 commit 5c47c35
Show file tree
Hide file tree
Showing 29 changed files with 3,449 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = LF
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@ircam",
}
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# transpiled files and dependencies
/node_modules
# application build files
.build
.data

# ignore all environment config files
/config/env-*

# junk files
package-lock.json
.DS_Store
Thumbs.db

# TLS certificates
/**/*.pem

#
public/soundbank/*
!/soundbank/.gitkeep
public/presets/*
!/presets/.gitkeep
public/calibration/*
public/analysis-data/*
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
5 changes: 5 additions & 0 deletions .soundworks
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "simone-realtime",
"eslint": true,
"language": "js"
}
28 changes: 28 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Copyright (c) 2014-present IRCAM – Centre Pompidou (France, Paris)

All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.

* Neither the name of the IRCAM nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13 changes: 13 additions & 0 deletions config/application.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
name: 'simone-realtime',
author: '',
clients: {
controller: {
target: 'browser',
default: true,
},
satellite: {
target: 'node',
},
},
}
44 changes: 44 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "simone-realtime",
"description": "soundworks application",
"authors": [],
"license": "BSD-3-Clause",
"version": "0.0.0",
"type": "module",
"private": true,
"scripts": {
"build": "npm run clean && sass src/clients/styles:.build/public/css && soundworks-build -b",
"build:production": "npm run clean && sass src/clients/styles:.build/public/css && soundworks-build -b -m",
"clean": "soundworks-build -D",
"dev": "npm run build && (concurrently -i -p \"none\" \"npm run watch:inspect server\" \"soundworks-build -b -w\" \"npm run watch:sass\")",
"postinstall": "soundworks-build -C",
"start": "node .build/server/index.js",
"watch": "soundworks-build -p",
"watch:inspect": "soundworks-build -d -p",
"watch:sass": "sass --watch src/clients/styles:.build/public/css",
"lint": "eslint ."
},
"dependencies": {
"@ircam/sc-components": "^3.0.0-alpha.44",
"@ircam/sc-loader": "^1.0.0-alpha.1",
"@ircam/sc-scheduling": "^0.1.6",
"@ircam/sc-utils": "^1.3.3",
"@soundworks/core": "^4.0.0-alpha.0",
"@soundworks/helpers": "^1.0.0-alpha.2",
"@soundworks/plugin-filesystem": "^2.0.0-alpha.6",
"@soundworks/plugin-platform-init": "^1.0.0-alpha.5",
"@soundworks/plugin-sync": "^2.0.0-alpha.3",
"json5": "^2.2.2",
"lit": "^3.0.2",
"node-web-audio-api": "^0.18.0",
"static-kdtree": "^1.0.2"
},
"devDependencies": {
"@ircam/eslint-config": "^1.2.1",
"@soundworks/build": "^1.0.0-alpha.0",
"@soundworks/create": "^1.0.0-alpha.19",
"concurrently": "^8.2.2",
"eslint": "^8.57.0",
"sass": "^1.57.1"
}
}
Binary file added public/favicon.ico
Binary file not shown.
Binary file added public/images/loader.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 78 additions & 0 deletions src/clients/components/sw-audit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { LitElement, html, css, nothing } from 'lit';
import { unsafeHTML } from 'lit/directives/unsafe-html.js';

function padLeft(value, size) {
let str = value + ''; // cast to string

while (str.length <= size) {
str = `&nbsp;${str}`;
}

return str;
}

/**
* Component for the soundworks internal audit state
*/
class SwAudit extends LitElement {
static styles = css`
:host > div {
background-color: var(--sw-light-background-color);
height: 100%;
padding: 0 20px;
overflow: hidden;
}
`;

constructor() {
super();

this.client = null;
this._auditState = null;
this._numClientsString = '';
}

async connectedCallback() {
super.connectedCallback();

this._auditState = await this.client.getAuditState();
this._auditState.onUpdate(updates => {
if ('numClients' in updates) {
const numClientsStrings = [];
const numClients = this._auditState.get('numClients');

for (let role in numClients) {
const str = `${role}: ${padLeft(numClients[role], 2)}`;
numClientsStrings.push(str);
}

this._numClientsString = numClientsStrings.join(' - ');
}

this.requestUpdate();
}, true);
}

disconnectedCallback() {
super.disconnectedCallback();

this._auditState.detach();
}

render() {
if (this._auditState === null) {
return nothing;
}

const avgLatency = this._auditState.get('averageNetworkLatency');
const avgLatencyString = padLeft((avgLatency * 1e3).toFixed(2), 6);

return html`
<div>
${unsafeHTML(this._numClientsString)} | avg latency: ${unsafeHTML(avgLatencyString)} ms
</div>
`;
}
}

customElements.define('sw-audit', SwAudit);
80 changes: 80 additions & 0 deletions src/clients/components/sw-credits.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { LitElement, html, css, nothing } from 'lit';

import '@ircam/sc-components/sc-icon.js';

class SwCredits extends LitElement {
static properties = {
_show: {
type: Boolean,
state: true,
},
};

static styles = css`
:host {
width: 100%;
position: fixed;
bottom: 0;
left: 0;
z-index: 1000;
}
:host > footer {
display: block;
line-height: 1.6rem;
padding: 20px;
background-color: var(--sw-light-background-color);
box-sizing: border-box;
}
footer span {
font-style: italic;
color: var(--sw-light-font-color);
font-weight: bold;
}
footer a {
color: var(--sw-light-font-color);
}
sc-icon {
position: absolute;
bottom: 20px;
right: 20px;
z-index: 1001;
border: none;
background-color: transparent;
opacity: 0.6;
}
`;

constructor() {
super();

this._show = false;
this.infos = {};
}

render() {
const $footer = html`
<footer>
<p>
<span>${this.infos.name}</span>
${this.infos.author ? html`by <span>${this.infos.author}</span>` : ``}
has been developped using the <a href="https://soundworks.dev" target="_blank">soundworks</a>
framework developped by the ISMM team at Ircam.
</p>
<p>
Copyright (c) 2014-present IRCAM – Centre Pompidou (France, Paris)
</p>
</footer>
`;

return html`
${this._show ? $footer : nothing}
<sc-icon type="question" @release=${e => this._show = !this._show}></sc-icon>
`
}
}

customElements.define('sw-credits', SwCredits);
Loading

0 comments on commit 5c47c35

Please sign in to comment.