Skip to content

Commit

Permalink
update client
Browse files Browse the repository at this point in the history
  • Loading branch information
deleolajide committed Jan 6, 2025
1 parent 87b0bb9 commit f10959f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 37 deletions.
2 changes: 1 addition & 1 deletion classes/jsp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
</td>
</tr>
<tr><td><b>Song Sequence</b></td><td><select id="songSequence" type="text" class="form-control input"></select></td><td></td></tr>
<tr id="active_streams" style="display:none"><td><b>Active Streams</b></td><td colspan=7><select id="activeStreams" type="text" class="form-control input"></select></td></tr>
<tr id="streams_list" style="display:none"><td><b>Active Streams</b></td><td colspan=7><select id="activeStreams" type="text" class="form-control input"></select></td></tr>
</table>
</div>
<div style="margin-top: 20px;">
Expand Down
57 changes: 22 additions & 35 deletions classes/jsp/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ const WHAMMY = 2;
const LOGO = 12;
const CONTROL = 100;

var _converse;
var activeStreams = null;
var _converse = null;
var recorderDestination = null;
var streamDestination = null;
var publishConnection = null;
Expand Down Expand Up @@ -943,13 +944,13 @@ async function fetchStreams() {
console.debug("fetchStreams", _converse);

const streamSong = document.querySelector("#stream_song");
const activeStreams = document.querySelector("#activeStreams");
activeStreams = document.querySelector("#activeStreams");
activeStreams.options[0] = new Option("**UNUSED**", "activeStreams", false, false);

activeStreams.addEventListener("click", async () => {
console.debug("fetchStreams refresh streams");

const res = await _converse.api.sendIQ($iq({type: 'get', to: _converse.api.domain}).c('whep', {xmlns: 'urn:xmpp:whep:0'}));
const res = await _converse.api.sendIQ(converse.env.$iq({type: 'get', to: _converse.api.domain}).c('whep', {xmlns: 'urn:xmpp:whep:0'}));
console.debug('fetchStreams response', res);
const items = res.querySelectorAll('item');
const temp = activeStreams.selectedIndex;
Expand Down Expand Up @@ -994,7 +995,7 @@ async function fetchStreams() {
watchConnection.setLocalDescription(offer);
console.debug('fetchStreams offer', offer.sdp);

const res = await _converse.api.sendIQ($iq({type: 'set', to: _converse.api.domain}).c('whep', {id: activeStreams.value, xmlns: 'urn:xmpp:whep:0'}).c('sdp', offer.sdp));
const res = await _converse.api.sendIQ(converse.env.$iq({type: 'set', to: _converse.api.domain}).c('whep', {id: activeStreams.value, xmlns: 'urn:xmpp:whep:0'}).c('sdp', offer.sdp));
console.debug('fetchStreams whep set response', res);
const answer = res.querySelector('sdp')?.innerHTML;
const json = res.querySelector('json')?.innerHTML;
Expand All @@ -1006,14 +1007,15 @@ async function fetchStreams() {

if (json) {
const metaData = JSON.parse(json);
tempo = metaData.tempo;
setTempo(metaData.tempo);
keyChange = metaData.keyChange;
dokeyChange();
}
})
}
});

const res = await _converse.api.sendIQ($iq({type: 'get', to: _converse.api.domain}).c('whep', {xmlns: 'urn:xmpp:whep:0'}));
const res = await _converse.api.sendIQ(converse.env.$iq({type: 'get', to: _converse.api.domain}).c('whep', {xmlns: 'urn:xmpp:whep:0'}));
console.debug('fetchStreams response', res);
const items = res.querySelectorAll('item');
let count = 1;
Expand Down Expand Up @@ -1054,7 +1056,7 @@ async function handleMediaStream(started) {
publishConnection.setLocalDescription(offer);
console.debug('handleMediaStream offer', offer.sdp);

const res = await _converse.api.sendIQ($iq({type: 'set', to: _converse.api.domain}).c('whip', {xmlns: 'urn:xmpp:whip:0'}).c('sdp').t(offer.sdp).up().c('json', {xmlns: 'urn:xmpp:json:0'}).t(JSON.stringify(json)));
const res = await _converse.api.sendIQ(converse.env.$iq({type: 'set', to: _converse.api.domain}).c('whip', {xmlns: 'urn:xmpp:whip:0'}).c('sdp').t(offer.sdp).up().c('json', {xmlns: 'urn:xmpp:json:0'}).t(JSON.stringify(json)));
const answer = res.querySelector('sdp').innerHTML;
publishConnection.setRemoteDescription({sdp: answer, type: 'answer'});
console.debug('handleMediaStream answer', answer);
Expand All @@ -1069,7 +1071,7 @@ async function handleMediaStream(started) {

function startXMPP() {
const streamSong = document.querySelector("#stream_song");
const activeStreams = document.querySelector("#active_streams");
const streamsList = document.querySelector("#streams_list");
const toggleChat = document.querySelector("#toggle_chat");
const chatview = document.querySelector("#chatview");

Expand Down Expand Up @@ -1133,7 +1135,7 @@ function startXMPP() {

_converse.api.listen.on('connected', function() {
streamSong.style.display = "";
activeStreams.style.display = "";
streamsList.style.display = "";
toggleChat.style.display = "";
streamSong.style.setProperty("--accent-fill-rest", "green");
setTimeout(fetchStreams);
Expand Down Expand Up @@ -2711,7 +2713,7 @@ function handleNoteOn(note, device, velocity, channel) {
tonic = Tonal.Midi.toMidi(detectedChord.tonic + "1") % 12;
}

orinayo.innerHTML = key + " - " + detectedChord.symbol;
// orinayo.innerHTML = key + " - " + detectedChord.symbol;
const chordKey = "key" + tonic + "_" + arrChordType + "_" + SECTION_IDS[sectionChange];
const bassKey = "key" + (chord[0] % 12) + "_" + arrChordType + "_" + SECTION_IDS[sectionChange];

Expand Down Expand Up @@ -5339,10 +5341,18 @@ function playChord(chord, root, type, bass) {
firstChord = chord;

if (inputDeviceType == "lavagenie" || inputDeviceType == "keyboard") pad.axis[STRUM] = autoStrumUpDown();

const arrChord = (firstChord.length == 4 ? firstChord[1] : firstChord[0]) % 12;
const key = "key" + arrChord + "_" + arrChordType + "_" + SECTION_IDS[sectionChange];
const bassKey = "key" + (bassNote % 12) + "_" + arrChordType + "_" + SECTION_IDS[sectionChange];
const chordSymbol = KEYS[arrChord] + arrChordType + (firstChord.length == 4 ? "/" + KEYS[(bassNote % 12)] : "");

orinayo.innerHTML = chordSymbol;

if (_converse && activeStreams && activeStreams.value != "activeStreams") {
_converse.api.send(converse.env.$msg({to: activeStreams.value + "@" + _converse.api.connection.get().domain, type: 'chat'}).c('body').t(chordSymbol));
}


if (guitarName != "none" && !guitarDeviceId)
{
Expand Down Expand Up @@ -6186,7 +6196,6 @@ function doChord() {
if (pad.buttons[YELLOW] && pad.buttons[BLUE] && pad.buttons[ORANGE] && pad.buttons[RED])
{
playChord([base - 12, base + 5, base + 9, base + 12], 0x34, 0x00, 0x31);
orinayo.innerHTML = key + " - " + "4/1";
}
else

Expand All @@ -6195,7 +6204,6 @@ function doChord() {
if (pad.buttons[YELLOW] && pad.buttons[BLUE] && pad.buttons[ORANGE] && pad.buttons[GREEN])
{
playChord([base - 12, base + 7, base + 11, base + 14], 0x35, 0x00, 0x31);
orinayo.innerHTML = key + " - " + "5/1";
}
else

Expand All @@ -6204,150 +6212,129 @@ function doChord() {
if (pad.buttons[RED] && pad.buttons[YELLOW] && pad.buttons[BLUE] && pad.buttons[GREEN])
{
playChord([base - 1, base + 3, base + 6], 0x37, 0x00, 0x37);
orinayo.innerHTML = key + " - " + "7";
}
else

if (pad.buttons[RED] && pad.buttons[YELLOW] && pad.buttons[GREEN]) // Ab
{
playChord([base - 4, base, base + 3], 0x26, 0x00, 0x26);
orinayo.innerHTML = key + " - " + "6b";
}
else

if (pad.buttons[RED] && pad.buttons[YELLOW] && pad.buttons[BLUE]) // A
{
playChord([base - 3, base + 13, base + 16], 0x36, 0x00, 0x36);
orinayo.innerHTML = key + " - " + "6";
}
else

if (pad.buttons[BLUE] && pad.buttons[YELLOW] && pad.buttons[GREEN]) // E
{
playChord([base - 8, base + 8, base + 11], 0x33, 0x00, 0x33);
orinayo.innerHTML = key + " - " + "3";
}
else


if (pad.buttons[BLUE] && pad.buttons[RED] && pad.buttons[ORANGE]) // Eb
{
//playChord([base - 29, base + 9, base + 12, base + 16]);
//orinayo.innerHTML = key + " - " + "Am/G";
//// orinayo.innerHTML = key + " - " + "Am/G";
playChord([base - 9, base + 7, base + 10], 0x23, 0x00, 0x23);
orinayo.innerHTML = key + " - " + "3b";
}
else

if (pad.buttons[YELLOW] && pad.buttons[BLUE] && pad.buttons[ORANGE]) // F/G
{
playChord([base - 17, base + 5, base + 9, base + 12], 0x34, 0x00, 0x35);
orinayo.innerHTML = key + " - " + "4/5";
}
else

if (pad.buttons[RED] && pad.buttons[YELLOW]) // Bb
{
playChord([base - 2, base + 2, base + 5], 0x27, 0x00, 0x27);
orinayo.innerHTML = key + " - " + "7b";
}
else

if (pad.buttons[GREEN] && pad.buttons[YELLOW]) // Gsus
{
playChord([base - 5, base + 12, base + 14], 0x35, 0x20, 0x35);
orinayo.innerHTML = key + " - " + "5sus";
}
else

if (pad.buttons[ORANGE] && pad.buttons[YELLOW]) // Csus
{
playChord([base, base + 5, base + 7], 0x31, 0x20, 0x31);
orinayo.innerHTML = key + " - " + "1sus";
}
else

if (pad.buttons[YELLOW] && pad.buttons[BLUE]) // C/E
{
playChord([base - 20, base, base + 4, base + 7], 0x31, 0x00, 0x33);
orinayo.innerHTML = key + " - " + "1/3";
}
else

if (pad.buttons[GREEN] && pad.buttons[RED]) // G/B
{
playChord([base - 13, base + 7, base + 11, base + 14], 0x35, 0x00, 0x37);
orinayo.innerHTML = key + " - " + "5/7";
}
else

if (pad.buttons[BLUE] && pad.buttons[ORANGE]) // F/A
{
playChord([base - 15, base + 5, base + 9, base + 12], 0x34, 0x00, 0x36);
orinayo.innerHTML = key + " - " + "4/6";
}
else

if (pad.buttons[GREEN] && pad.buttons[BLUE]) // Em
{
playChord([base - 8, base + 7, base + 11], 0x33, 0x08, 0x33);
orinayo.innerHTML = key + " - " + "3m";
}
else

if (pad.buttons[ORANGE] && pad.buttons[RED]) // Fm
{
playChord([base - 7, base + 8, base + 12], 0x34, 0x08, 0x34);
orinayo.innerHTML = key + " - " + "4m";
}
else

if (pad.buttons[GREEN] && pad.buttons[ORANGE]) // Gm
{
playChord([base - 5, base + 10, base + 14], 0x35, 0x08, 0x35);
orinayo.innerHTML = key + " - " + "5m";
}
else

if (pad.buttons[RED] && pad.buttons[BLUE]) // D
{
playChord([base + 2, base + 6, base + 9], 0x32, 0x00, 0x32);
orinayo.innerHTML = key + " - " + "2";
}
else

if (pad.buttons[YELLOW]) // C
{
playChord([base, base + 4, base + 7], 0x31, 0x00, 0x31);
orinayo.innerHTML = key + " - " + "1";
}
else

if (pad.buttons[BLUE]) // Dm
{
playChord([base + 2, base + 5, base + 9], 0x32, 0x08, 0x32);
orinayo.innerHTML = key + " - " + "2m";
}
else

if (pad.buttons[ORANGE]) // F
{
playChord([base - 7, base + 9, base + 12], 0x34, 0x00, 0x34);
orinayo.innerHTML = key + " - " + "4";
}
else

if (pad.buttons[GREEN]) // G
{
playChord([base - 5, base + 11, base + 14], 0x35, 0x00, 0x35);
orinayo.innerHTML = key + " - " + "5";
}
else

if (pad.buttons[RED]) // Am
{
playChord([base - 3, base + 12, base + 16], 0x36, 0x08, 0x36);
orinayo.innerHTML = key + " - " + "6m";
}
}

Expand Down
2 changes: 1 addition & 1 deletion docs/xep/xep-xxxx-user_media_streams-01-01.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<section1 topic='Introduction' anchor='intro'>
<p>While WebRTC specifies the usage of SDPs [RFC8866] and an Offer/Answer model [RFC3264] for creating connections, WebRTC does not define the precise signaling protocols over which SDPs should be exchanged [RFC8825]. In order to establish a WebRTC session between two WebRTC entities, a signaling protocol is usually used to exchange SDPs</p>
<p>With HTTP/S applications, WHIP and WHEP have been proposed as simple protocols to ingest and egress media streams using WebRTC.</p>
<p>This specification provideds the means to do likewise in XMPP for communicating user media streams using WebRTC-based ingestion/egress. The WebRTC SDP payload format is transported using IQ stanzas which map directly to WHIP and WHEP REST endpoints.</p>
<p>This specification provides the means to do likewise in XMPP for communicating user media streams using WebRTC-based ingestion/egress. The WebRTC SDP payload format is transported using IQ stanzas which map directly to WHIP and WHEP REST endpoints.</p>
<p>This specification does not prescribe a method for the discovery, publishing and subscription of available URIs for WHIP and WHEP. It is assumed that this will be achieved with other XMPP mechanisms like Publish-Subscribe (&xep0060;) or HTTP Online Meetings (&xep0483;) for example.</p>
</section1>
<section1 topic="Requirements" anchor="reqs">
Expand Down

0 comments on commit f10959f

Please sign in to comment.