Skip to content

Commit

Permalink
Added volume control, panic switch, sound solo options, misc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
brandoshizzle committed Jan 5, 2019
1 parent 0eea829 commit 959dad8
Show file tree
Hide file tree
Showing 16 changed files with 111 additions and 1,421 deletions.
18 changes: 8 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,30 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [0.6.0] - 2018-05-22
### Added
- Volume control for individual sounds
- Double-click volume bar to reset to 100%

### Changed
- Misc fonts/logos related to new name
- JEditable updated to v2.02

## [0.5.0] - 2018-05-09
## [0.5.0] - XXXX-XX-XX
### Added
- Panic switch (Global stop) by pressing ESCAPE
- Solo sound options - choose to auto-stop playing sounds when a new sound starts
- Volume control for individual sounds
- Double-click volume bar to reset to 100%

### Fixed
- Fixed issue with playlist not switching song after fade out
- Fixed issue with loaded bar not hiding when errors loading songs
- Removed missed restricted characters from song ids
- General refactoring and cleaning of code

### Changed
- Name (Wowee!)
- Misc fonts/logos related to new name
- JEditable updated to v2.02
- Removed dragging of keys
- Enlarged the playlist box vertically
- Upgraded to Interact.js v1.3.3
- Upgraded Howler.js to v2.0.10
- Updated npm package dependencies


## [0.4.1] - 2017-05-25
### Added
- Playlist: Dropdown on playlist header to access action items
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ app.on('ready', function() {
var win = new BrowserWindow();
win.maximize();
win.loadURL('file://' + __dirname + '/src/main.html');
//win.openDevTools();
win.openDevTools();
});

app.on('window-all-closed', function() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Flask",
"version": "0.6.0",
"version": "0.5.0",
"description": "Software for improvising sound",
"main": "index.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions src/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ tr td {
border: 2px solid gray;
border-radius: 4px;
background-color: var(--oc-gray-2);
z-index: 1000;
}

.color-picker-color {
Expand Down
12 changes: 9 additions & 3 deletions src/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,9 @@ <h5 id="sound-settings-name" class="header editable" style="text-align: center">
<div id="color-pink" class="color-picker-color"></div>
<div id="color-grape" class="color-picker-color"></div>
<div id="color-violet" class="color-picker-color"></div>
<!--<div id="color-indigo" class="color-picker-color"></div>-->
<div id="color-blue" class="color-picker-color"></div>
<div id="color-cyan" class="color-picker-color"></div>
<div id="color-teal" class="color-picker-color"></div>
<!--<div id="color-green" class="color-picker-color"></div>-->
<div id="color-lime" class="color-picker-color"></div>
<div id="color-yellow" class="color-picker-color"></div>
<div id="color-orange" class="color-picker-color"></div>
Expand All @@ -238,7 +236,7 @@ <h6>Making improvising sound easy.</h6>
</p>
<p>Like Flask? <a href="http://paypal.me/BrandonCathcart">Buy me a beer! :)</a></p>
<span style="font-size: 11px">
<p>Copyright 2017 Brandon Cathcart</p>
<p>Copyright 2019 Brandon Cathcart</p>
<p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at </p>
<p><a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a></p>
<p>Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
Expand Down Expand Up @@ -307,6 +305,14 @@ <h3>Fade Out</h3>
<label>seconds</label>
</div>
</div>
<div class="row">
<div class="settings-description col s9">
<h3>Set all volumes to 100%</h3>
</div>
<div class="settings-switch col s3">
<div class="btn btn-settings" id="settings-resetVolume" style="float: right;" onclick="settings.resetVolumes()">Reset</div>
</div>
</div>
</div>
</div>

Expand Down
4 changes: 2 additions & 2 deletions src/scripts/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function setKeyEvents() {
}
var id = targetKey.attr('id');
// Create a new sound info object
newSoundInfo = soundInfoManager.createSoundInfoFromPath(f.path, id);
newSoundInfo = soundInfoManager.createNewSoundInfo(f.path, id);
// Store the new sound info object in the keyInfo object
keyInfo[id] = newSoundInfo;
targetKey.find('.audioName').text(newSoundInfo.name);
Expand Down Expand Up @@ -72,7 +72,7 @@ function setKeyEvents() {
var first = true;
for (let f of e.originalEvent.dataTransfer.files) {
// Create new soundInfo object
var newSoundInfo = soundInfoManager.createSoundInfoFromPath(f.path);
var newSoundInfo = soundInfoManager.createNewSoundInfo(f.path);
playlistInfo[newSoundInfo.id] = newSoundInfo;
view.createPlaylistItem(newSoundInfo); // Create a new li in the playlist
if(first){
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ $(document).ready(function() {
keyInfo[targetId].id = targetId;
try {
pagesInfo['page' + dragStartPage].keyInfo[draggedId].id = draggedId;
sounds.register(pagesInfo['page' + dragStartPage].keyInfo[draggedId]);
sounds.createNewHowl(pagesInfo['page' + dragStartPage].keyInfo[draggedId]);
} catch(err){
draggedInfo = {};
storage.checkAgainstDefault(draggedInfo, 'soundInfo');
Expand All @@ -217,7 +217,7 @@ $(document).ready(function() {
delete pagesInfo['page' + dragStartPage].keyInfo[draggedId];
}
// re-register the sounds
sounds.register(keyInfo[targetId]);
sounds.createNewHowl(keyInfo[targetId]);
view.updateKey(keyInfo[targetId]);
if(currentPage === dragStartPage && keyInfo[draggedId] !== undefined){
keyInfo = pagesInfo['page'+currentPage].keyInfo; // updates properly
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function registerKeyInfos(){
delete tempKeyInfo[id];
} else {
$("#" + tempKeyInfo[id].id).find('.audioName').text(tempKeyInfo[id].name);
sounds.register(tempKeyInfo[id]);
sounds.createNewHowl(tempKeyInfo[id]);
}
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function registerPlaylistItems() {
$("#" + playlistInfo[id].id)
.find(".audioName")
.text(playlistInfo[id].name);
sounds.register(playlistInfo[id]);
sounds.createNewHowl(playlistInfo[id]);
});

// Set Sortable list
Expand Down
19 changes: 17 additions & 2 deletions src/scripts/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function saveSoundSettings() {
var tempSoundInfo = settingsSoundInfo;
if (tempSoundInfo.path != $("#sound-settings-path").val()) {
tempSoundInfo.path = $("#sound-settings-path").val();
sounds.register(tempSoundInfo);
sounds.createNewHowl(tempSoundInfo);
waveforms.load(tempSoundInfo);
//view.resetEndTime();
//view.resetStartTime();
Expand Down Expand Up @@ -197,6 +197,20 @@ function resetFade(soundOrPage, inOrOut) {
}
}

function resetVolumes(){
for(var page in pagesInfo){
for(var key in pagesInfo[page].keyInfo){
pagesInfo[page].keyInfo[key].volume = 0.8;
}
}
for(var sound in playlistInfo){
playlistInfo[sound].volume = 0.8;
}
keyInfo = pagesInfo.page1.keyInfo;
storage.storeObj("pagesInfo", pagesInfo);
storage.storeObj("playlistInfo", playlistInfo);
}

function openPageSettings(pageNum) {
var pageInfo = pagesInfo["page" + pageNum];
if (pageInfo.name) {
Expand Down Expand Up @@ -242,5 +256,6 @@ module.exports = {
saveSoundSettings: saveSoundSettings,
resetFade: resetFade,
openPageSettings: openPageSettings,
savePageSettings: savePageSettings
savePageSettings: savePageSettings,
resetVolumes: resetVolumes
};
66 changes: 22 additions & 44 deletions src/scripts/soundInfoManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,27 @@ var defaultSoundInfo = sounds.defaultSoundInfo();
/**
* @desc: Takes a path and (optional) id and returns a default soundInfo object
* @param: path: the complete path to the sound file
id: (optional) The id for the sound. Defaults to default name
id: (optional) The id for the sound. Defaults to default name
*/
function createSoundInfoFromPath(path, id) {
var tempObj = util.cloneObj(defaultSoundInfo);
storage.checkAgainstDefault(tempObj, 'soundInfo');
// Write known info
tempObj.name = util.cleanName(path);
tempObj.id = id || util.prepareForId(tempObj.name);
tempObj.path = path;
// Define which section it is part of
function createNewSoundInfo(path, id) {
// Get template
var newSoundInfo = util.cloneObj(defaultSoundInfo);
//storage.checkAgainstDefault(tempObj, 'soundInfo');
// Write new specific info
newSoundInfo.name = util.cleanName(path);
newSoundInfo.id = id || util.prepareForId(tempObj.name);
newSoundInfo.path = path;

// Define which section it is part of - id will be undefined if it's in the playlist
if(id === undefined){
tempObj.infoObj = "playlist";
// New sound is in the playlist
newSoundInfo.infoObj = "playlist";
// Create a unique id for the playlist item (to allow multiple of same!)
var count = 0;
var duplicate, tempId;
do {
duplicate = false;
tempId = (count > 0) ? tempObj.id + count : tempObj.id;
tempId = (count > 0) ? newSoundInfo.id + count : newSoundInfo.id;
for (var item in playlistInfo) {
if(playlistInfo[item].id == tempId){
duplicate = true;
Expand All @@ -31,42 +34,17 @@ function createSoundInfoFromPath(path, id) {
}
}
} while (duplicate);
tempObj.id = (count > 0) ? tempId : tempObj.id;
} else {
tempObj.infoObj = "key";
}
sounds.register(tempObj);
// INSTANCE IS CREATED AND END TIME IS CALCULATED WHEN SONG PRELOADS - SEE SOUNDS.JS
return tempObj;
}

/**
* @desc: Ensures that all loaded keys have the properties they need
* Called when loading stored keyInfo and when a song is dragged onto a key
* @param: key: The letter (or character) of the key to check (string)
*/
function checkSoundInfo(id, infoObj) {
if (infoObj[id] === undefined) { // If that key isn't part of the keyInfo array yet...
infoObj[id] = JSON.parse(JSON.stringify(defaultSoundInfo));
} else { // If key was already defined...
// Check that the key has all properties - set default if it doesn't have it.
Object.keys(defaultSoundInfo).map(function(prop, index) {
if (!infoObj[id].hasOwnProperty(prop)) {
infoObj[id][prop] = defaultSoundInfo[prop];
}
});

// Check that the key does not have depreciated properties (and delete them)
Object.keys(infoObj[id]).map(function(prop, index) {
if (!defaultSoundInfo.hasOwnProperty(prop)) {
delete infoObj[id][prop];
}
});
newSoundInfo.id = (count > 0) ? tempId : newSoundInfo.id;

} else {
// New sound is in the pages
newSoundInfo.infoObj = "key";
}
// Create howl instance
sounds.createNewHowl(newSoundInfo);
return newSoundInfo;
}

module.exports = {
createSoundInfoFromPath: createSoundInfoFromPath,
checkSoundInfo: checkSoundInfo
createNewSoundInfo: createNewSoundInfo,
};
48 changes: 25 additions & 23 deletions src/scripts/sounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var stopping = 0;
* Sounds that fail the path check get the soundNotLoaded class
* @param: soundInfo: Object containing info related to the sound object
*/
function registerSound(soundInfo) {
function createNewHowl(soundInfo) {
// Check if path to sound file exists
if (fs.existsSync(soundInfo.path)) {
// Register sound with Howler
Expand All @@ -27,13 +27,10 @@ function registerSound(soundInfo) {
if (soundInfo.endTime === null) {
soundInfo.endTime = soundInfo.howl.duration();
}

loadedCount++;
var loadedPercent = loadedCount / totalNumSounds * 100 + "%";
$("#loadedCount").width(loadedPercent);
if (loadedCount === totalNumSounds) {
$("#loadedContainer").css("display", "none");
}
addToLoadingBar();
},
onloaderror: function(){
addToLoadingBar();
},
onplay: function() {
var fadeTime = getFadeTime(soundInfo, "in");
Expand Down Expand Up @@ -61,18 +58,21 @@ function registerSound(soundInfo) {
soundInfo.startTime / soundInfo.howl.duration()
);
}
/*
onfade: function(){
if(stopping){
stop(soundInfo);
stopping = false;
}
}*/
});
} else {
// Let the user know with a toast
// Song path does not exist - don't load the song
Materialize.toast(soundInfo.name + " was not found.", 3000);
$("#" + soundInfo.id).addClass("soundNotLoaded");
addToLoadingBar();
}
}

function addToLoadingBar(){
loadedCount++;
var loadedPercent = loadedCount / totalNumSounds * 100 + "%";
$("#loadedCount").width(loadedPercent);
if (loadedCount === totalNumSounds) {
$("#loadedContainer").css("display", "none");
}
}

Expand All @@ -89,13 +89,11 @@ function playSound(soundInfo) {
}

if (soundInfo.howl.playing()) {
// Song is playing. Fade it out
soundInfo.fadeOut();
// Song is not playing, so play it.
return;
} else {
play();
}

function play() {
// Song is not playing, so play it.
var key;
if (soundInfo.infoObj === "playlist") {
if (playlistPlayingSoundInfo !== undefined) {
Expand All @@ -112,7 +110,7 @@ function playSound(soundInfo) {
var fadeTime = getFadeTime(soundInfo, "in");
soundInfo.howl.volume(fadeTime > 0 ? 0 : 1);

// Fade out currently playing sounds if user has selected that option
// Fade out currently playing sounds if user has selected solo sounds
if (
(settingsInfo.pages.soloSound === "pages" ||
settingsInfo.pages.soloSound === "all") &&
Expand Down Expand Up @@ -183,6 +181,10 @@ function getDuration(soundInfo) {
return (soundInfo.howl.duration() / 1000).toFixed(2);
}

/**
* @desc: The constructor function for a new sound info object.
* @param: None.
*/
function defaultSoundInfo() {
return {
id: "",
Expand Down Expand Up @@ -281,7 +283,7 @@ function getFadeTime(soundInfo, direction) {
}

module.exports = {
register: registerSound,
createNewHowl: createNewHowl,
playSound: playSound,
getDuration: getDuration,
stop: stop,
Expand Down
5 changes: 5 additions & 0 deletions src/scripts/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ function emptyObj(objName, obj){
storeObj(objName, obj);
}

/**
* @desc: Ensures that all loaded settings and soundInfos have the properties they need
* Called when loading stored keyInfo and settings
* @param: key: The letter (or character) of the key to check (string)
*/
function checkAgainstDefault(obj, defaultName) {
var changed = false;
// Update the object with any new properties
Expand Down
Loading

0 comments on commit 959dad8

Please sign in to comment.