Skip to content

Commit

Permalink
fix slice update (fss)
Browse files Browse the repository at this point in the history
fix slice deletion (fss)
fix unavailable slice settings
fix MIDI devices hot plugging
fix osc. count display (osc. count is now displayed per channels)
  • Loading branch information
grz0zrg committed Feb 26, 2017
1 parent 91facb6 commit 08a3b5d
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 87 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Fragment can also be used for live coding visuals, they can be synchronized to s
* Stereophonic
* Polyphonic
* Multitimbral
* Adjustable audio output per slices
* Aliasing free
* Adjustable audio output channel per slices
* Shader inputs, webcam, textures and more
* Real-time analysis (logarithmic spectrum view of the output etc.)
* Native app. powered by [Electron](http://electron.atom.io/) with built-in [C powered additive synthesizer](https://github.com/grz0zrg/fas)
Expand All @@ -37,8 +38,8 @@ Fragment can also be used for live coding visuals, they can be synchronized to s

* Recent browser such as Chrome, Opera, Safari or Firefox (WebMIDI is still not supported by Firefox)
* Recent medium GPU (Graphics Processing Unit), this app. was made and is used with a GeForce GTX 970
* Recent medium multi-core CPU (a dual core should be ok with the native program), this is required for the audio synthesis part
* Not necessary but a MIDI device such as a MIDI keyboard is recommended
* Recent medium multi-core CPU (a dual core should be ok with the native program, a beefy CPU is needed if you use more than one output channel), this is required for the audio synthesis part
* Not necessary but a MIDI device such as a MIDI keyboard and a MIDI controller is recommended

## The project

Expand Down
64 changes: 33 additions & 31 deletions client/dist/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -16740,7 +16740,7 @@ var _frame = function (raf_time) {
iglobal_time,

date = new Date(),

channel = 0,
channel_data,

Expand Down Expand Up @@ -16856,6 +16856,25 @@ var _frame = function (raf_time) {
buffer.push(new Uint8Array(/*_data[i]*/_canvas_height_mul4));
}

if (_show_oscinfos) {
var arr_infos = [];
for (j = 0; j < _output_channels; j += 1) {
var c = 0;

for (i = 0; i < _canvas_height_mul4; i += 4) {
if (_data[j][i] > 0) {
c += 1;
} else if (_data[j][i + 1] > 0) {
c += 1;
}
}

arr_infos.push(c);
}

_osc_infos.innerHTML = arr_infos.join(" ");
}

if (fas_enabled) {
_fasNotifyFast(_FAS_FRAME, _data);
} else {
Expand All @@ -16872,25 +16891,6 @@ var _frame = function (raf_time) {
}
}

if (_show_oscinfos) {
var arr_infos = [];
for (j = 0; j < _output_channels; j += 1) {
var c = 0;

for (i = 0; i < _canvas_height_mul4; i += 4) {
if (_data[j][i] > 0) {
c += 1;
} else if (_data[j][i + 1] > 0) {
c += 1;
}
}

arr_infos.push(c);
}

_osc_infos.innerHTML = arr_infos.join(" ");
}

if (_show_polyinfos) {
_poly_infos_element.innerHTML = _keyboard.polyphony;
}
Expand Down Expand Up @@ -18314,12 +18314,6 @@ var _computeOutputChannels = function () {
};

var _removePlayPositionMarker = function (marker_id, force, submit) {
/* if (_play_position_markers.length === 1 && force === undefined) {
_notification("Cannot remove the remaining slice.")

return;
}
*/
var play_position_marker = _play_position_markers[parseInt(marker_id, 10)],
slice_settings_container = document.getElementById("slice_settings_container_" + marker_id),
i;
Expand All @@ -18331,6 +18325,10 @@ var _removePlayPositionMarker = function (marker_id, force, submit) {
WUI.undraggable(play_position_marker.element.lastElementChild);

play_position_marker.element.parentElement.removeChild(play_position_marker.element);

WUI_RangeSlider.destroy("fs_slice_settings_x_input_" + marker_id);
WUI_RangeSlider.destroy("fs_slice_settings_shift_input_" + marker_id);
WUI_RangeSlider.destroy("fs_slice_settings_channel_input_" + marker_id);

_play_position_markers.splice(marker_id, 1);

Expand Down Expand Up @@ -20080,6 +20078,10 @@ var _addMIDIDevice = function (midi_input) {
if (midi_device_enabled) {
midi_device_enabled_ck = "checked";
}

if (_midi_devices.input[midi_input.id].connected) {
return;
}
}

midi_input_element.classList.add("fs-midi-settings-device");
Expand All @@ -20103,7 +20105,8 @@ var _addMIDIDevice = function (midi_input) {
version: midi_input.version,
iid: _midi_device_uid,
enabled: midi_device_enabled,
element: midi_input_element
element: midi_input_element,
connected: true
};

document.getElementById(midi_input_enabled_ck_id).addEventListener("change", function () {
Expand Down Expand Up @@ -20134,14 +20137,13 @@ var _deleteMIDIDevice = function (id) {

var _onMIDIAccessChange = function (connection_event) {
var device = connection_event.port;

// only inputs are supported at the moment
if (device.type !== "input") {
return;
}

if ((device.connection === "open" || device.connection === "pending") &&
device.state === "connected") {

if (device.state === "connected") {
_addMIDIDevice(device);
} else if (device.state === "disconnected") {
_deleteMIDIDevice(device.id);
Expand Down
22 changes: 11 additions & 11 deletions client/dist/fs.min.js

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions client/js/graphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ var _frame = function (raf_time) {
iglobal_time,

date = new Date(),

channel = 0,
channel_data,

Expand Down Expand Up @@ -369,6 +369,25 @@ var _frame = function (raf_time) {
buffer.push(new Uint8Array(/*_data[i]*/_canvas_height_mul4));
}

if (_show_oscinfos) {
var arr_infos = [];
for (j = 0; j < _output_channels; j += 1) {
var c = 0;

for (i = 0; i < _canvas_height_mul4; i += 4) {
if (_data[j][i] > 0) {
c += 1;
} else if (_data[j][i + 1] > 0) {
c += 1;
}
}

arr_infos.push(c);
}

_osc_infos.innerHTML = arr_infos.join(" ");
}

if (fas_enabled) {
_fasNotifyFast(_FAS_FRAME, _data);
} else {
Expand All @@ -385,25 +404,6 @@ var _frame = function (raf_time) {
}
}

if (_show_oscinfos) {
var arr_infos = [];
for (j = 0; j < _output_channels; j += 1) {
var c = 0;

for (i = 0; i < _canvas_height_mul4; i += 4) {
if (_data[j][i] > 0) {
c += 1;
} else if (_data[j][i + 1] > 0) {
c += 1;
}
}

arr_infos.push(c);
}

_osc_infos.innerHTML = arr_infos.join(" ");
}

if (_show_polyinfos) {
_poly_infos_element.innerHTML = _keyboard.polyphony;
}
Expand Down
14 changes: 9 additions & 5 deletions client/js/midi.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ var _addMIDIDevice = function (midi_input) {
if (midi_device_enabled) {
midi_device_enabled_ck = "checked";
}

if (_midi_devices.input[midi_input.id].connected) {
return;
}
}

midi_input_element.classList.add("fs-midi-settings-device");
Expand All @@ -92,7 +96,8 @@ var _addMIDIDevice = function (midi_input) {
version: midi_input.version,
iid: _midi_device_uid,
enabled: midi_device_enabled,
element: midi_input_element
element: midi_input_element,
connected: true
};

document.getElementById(midi_input_enabled_ck_id).addEventListener("change", function () {
Expand Down Expand Up @@ -123,14 +128,13 @@ var _deleteMIDIDevice = function (id) {

var _onMIDIAccessChange = function (connection_event) {
var device = connection_event.port;

// only inputs are supported at the moment
if (device.type !== "input") {
return;
}

if ((device.connection === "open" || device.connection === "pending") &&
device.state === "connected") {

if (device.state === "connected") {
_addMIDIDevice(device);
} else if (device.state === "disconnected") {
_deleteMIDIDevice(device.id);
Expand Down
10 changes: 4 additions & 6 deletions client/js/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,6 @@ var _computeOutputChannels = function () {
};

var _removePlayPositionMarker = function (marker_id, force, submit) {
/* if (_play_position_markers.length === 1 && force === undefined) {
_notification("Cannot remove the remaining slice.")
return;
}
*/
var play_position_marker = _play_position_markers[parseInt(marker_id, 10)],
slice_settings_container = document.getElementById("slice_settings_container_" + marker_id),
i;
Expand All @@ -276,6 +270,10 @@ var _removePlayPositionMarker = function (marker_id, force, submit) {
WUI.undraggable(play_position_marker.element.lastElementChild);

play_position_marker.element.parentElement.removeChild(play_position_marker.element);

WUI_RangeSlider.destroy("fs_slice_settings_x_input_" + marker_id);
WUI_RangeSlider.destroy("fs_slice_settings_shift_input_" + marker_id);
WUI_RangeSlider.destroy("fs_slice_settings_channel_input_" + marker_id);

_play_position_markers.splice(marker_id, 1);

Expand Down
20 changes: 10 additions & 10 deletions fss/fss.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ redisClient.on('connect', function() {

redisSettingsClient.get(session, function (err, reply) {
if (reply !== null) {
console.log(JSON.parse(reply));
//console.log(JSON.parse(reply));
ws.send(prepareMessage("slices", { data : JSON.parse(reply) }));
} else {
redisSettingsClient.set(session, "[]");
Expand Down Expand Up @@ -311,7 +311,7 @@ redisClient.on('connect', function() {
if (reply !== null) {
var slices = JSON.parse(reply);

slices.splice(parseInt(msg.id, 10), 1);
slices.splice(parseInt(msg.data.id, 10), 1);

clusterWideBroadcast(ws, prepareMessage("delSlice", { data: msg.data }), client.session);

Expand All @@ -320,7 +320,7 @@ redisClient.on('connect', function() {
});
} else if (msg.type === "updSlice") {
var client = fs.clients[ws.uid];

if (client === undefined) {
logger.error('Cannot find client id "%s"', ws.uid);

Expand All @@ -331,27 +331,27 @@ redisClient.on('connect', function() {
if (reply !== null) {
var slices = JSON.parse(reply),
slice = slices[parseInt(msg.data.id, 10)];

if (!slice) {
return;
}

if (msg.data.obj.x) {
if (msg.data.obj['x'] !== undefined) {
slice.x = msg.data.obj.x;
}

if (msg.data.obj.shift) {
if (msg.data.obj['shift'] !== undefined) {
slice.shift = msg.data.obj.shift;
}
if (msg.data.obj.mute) {

if (msg.data.obj['mute'] !== undefined) {
slice.mute = msg.data.obj.mute;
}

if (msg.data.obj.output_channel) {
if (msg.data.obj['output_channel'] !== undefined) {
slice.output_channel = msg.data.obj.output_channel;
}

clusterWideBroadcast(ws, prepareMessage("updSlice", { data: msg.data }), client.session);

redisSettingsClient.set(client.session, JSON.stringify(slices));
Expand Down

0 comments on commit 08a3b5d

Please sign in to comment.