Skip to content

Commit

Permalink
Added dedicated mixer window
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Zinken committed Jan 26, 2020
1 parent ffad171 commit 90023a0
Show file tree
Hide file tree
Showing 11 changed files with 293 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
"square": "Square",
"sawtooth": "Sawtooth",
"triangle": "Triangle",
"mixer": "Mixer",
"volumeTitle": "Volume",
"panTitle": "Panning",
"filterTitle": "EQ / Filter",
"odDelayTitle": "Overdrive / Delay",
"eqLegend": "Equalizer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,6 @@
<template>
<section class="module-editor">
<div class="module-list">
<fieldset class="instrument-parameters">
<legend v-t="'mixer'"></legend>
<div class="wrapper input range">
<label v-t="'volumeTitle'" for="instrumentVolume"></label>
<input v-model="volume"
type="range"
id="instrumentVolume"
min="0" max="1" step=".01" value="0" />
</div>
<div v-if="supportsPanning"
class="wrapper input range"
>
<label v-t="'panTitle'" for="instrumentPanning"></label>
<input v-model="panning"
type="range"
id="instrumentPanning"
min="-1" max="1" step=".01" value="0" />
</div>
</fieldset>

<ul class="modules-tabs tab-list">
<li v-t="'filterTitle'"
:class="{ active: activeModuleTab === 0 }"
Expand Down Expand Up @@ -187,7 +167,6 @@

<script>
import { mapMutations } from 'vuex';
import { supports } from '@/services/audio/webaudio-helper';
import AudioService from '@/services/audio-service';
import messages from './messages.json';
Expand All @@ -205,25 +184,8 @@ export default {
},
data: () => ({
activeModuleTab: 0,
supportsPanning: true,
}),
computed: {
volume: {
get() { return this.instrumentRef.volume; },
set(value) {
this.updateInstrument({ instrumentIndex: this.instrumentId, prop: 'volume', value });
AudioService.adjustInstrumentVolume(this.instrumentId, value);
this.invalidate();
}
},
panning: {
get() { return this.instrumentRef.panning; },
set(value) {
this.updateInstrument({ instrumentIndex: this.instrumentId, prop: 'panning', value });
AudioService.adjustInstrumentPanning(this.instrumentId, value);
this.invalidate();
}
},
/* EQ */
eqEnabled: {
get() { return this.instrumentRef.eq.enabled },
Expand Down Expand Up @@ -317,9 +279,6 @@ export default {
set(value) { this.update('delay', { ...this.instrumentRef.delay, offset: value }); }
},
},
created() {
this.supportsPanning = supports('panning');
},
methods: {
...mapMutations([
'updateInstrument',
Expand All @@ -342,7 +301,7 @@ export default {
.module-editor {
vertical-align: top;
padding: 0 $spacing-large;
margin-top: -$spacing-medium;
margin-top: $spacing-large;
@include boxSize();
.modules-tabs {
Expand Down Expand Up @@ -399,6 +358,7 @@ export default {
.module-editor {
width: 100%;
padding: 0;
margin-top: $spacing-xlarge;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/instrument-editor/instrument-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<option v-for="(instrument, idx) in instrumentAmount"
:key="`instrument_${idx}`"
:value="idx"
>{{ $t('instrument', { index: idx }) }}</option>
>{{ $t('instrument', { index: idx + 1 }) }}</option>
</select>
</div>

Expand Down
154 changes: 154 additions & 0 deletions src/components/mixer/components/channel-strip.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
/**
* The MIT License (MIT)
*
* Igor Zinken 2020 - https://www.igorski.nl
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the 'Software'), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
<template>
<div class="channel-strip">
<h3>{{ title }}</h3>
<h4 class="preset-name">{{ name }}</h4>
<div class="wrapper input range volume-wrapper">
<label v-t="'volumeTitle'"
for="instrumentVolume"
class="volume-title"
></label>
<input v-model="volume"
type="range"
id="instrumentVolume"
min="0" max="1" step="0.01" value="1"
class="range"
/>
</div>
<div v-if="supportsPanning"
class="wrapper input range panning-wrapper"
>
<label v-t="'panTitle'"
for="instrumentPanning"
></label>
<input v-model="panning"
type="range"
id="instrumentPanning"
min="-1" max="1" step=".01" value="0"
class="range"
/>
</div>
</div>
</template>

<script>
import { mapState, mapMutations } from 'vuex';
import AudioService from '@/services/audio-service';
import { supports } from '@/services/audio/webaudio-helper';
export default {
props: {
instrumentIndex: {
type: Number,
required: true,
},
},
data: vm => ({
title: `# ${vm.instrumentIndex + 1}`,
supportsPanning: false,
}),
computed: {
...mapState({
activeSong: state => state.song.activeSong,
}),
instrument() {
return this.activeSong.instruments[ this.instrumentIndex ];
},
name() {
return (this.instrument.presetName || this.instrument.name || '').replace('FACTORY ', '');
},
volume: {
get() {
return this.instrument.volume;
},
set( value ) {
this.updateInstrument({ instrumentIndex: this.instrumentIndex, prop: 'volume', value });
AudioService.adjustInstrumentVolume( this.instrumentIndex, value );
}
},
panning: {
get() {
return this.instrument.panning;
},
set( value ) {
this.updateInstrument({ instrumentIndex: this.instrumentIndex, prop: 'panning', value });
AudioService.adjustInstrumentPanning( this.instrumentIndex, value );
}
},
},
created() {
this.supportsPanning = supports('panning');
},
methods: {
...mapMutations([
'updateInstrument',
]),
},
};
</script>

<style lang='scss' scoped>
@import '@/styles/_layout.scss';
$width: 80px;
.channel-strip {
width: $width;
display: inline-block;
margin: $spacing-medium 0;
padding: 0 0 $spacing-large $spacing-medium;
border-right: 1px solid #666;
position: relative;
}
.preset-name {
@include textOverflow();
margin-left: -$spacing-medium;
font-size: 75%;
text-align: center;
height: 1.5em;
background-color: $color-2;
padding: 5px;
color: #000;
}
.range {
width: 125px;
height: 25px;
}
.volume-title {
margin-left: $spacing-small;
}
.volume-wrapper {
transform: rotate(-90deg);
transform-origin: 0;
margin: 130px 0 0 8px;
}
.panning-wrapper {
width: 70px;
}
</style>
7 changes: 7 additions & 0 deletions src/components/mixer/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"en-US": {
"title": "Mixer",
"volumeTitle": "Volume",
"panTitle": "Panning"
}
}
98 changes: 98 additions & 0 deletions src/components/mixer/mixer.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/**
* The MIT License (MIT)
*
* Igor Zinken 2020 - https://www.igorski.nl
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the 'Software'), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
<template>
<div class="mixer">
<div class="header">
<h2 v-t="'title'"></h2>
<button class="close-button"
@click="$emit('close')"
>x</button>
</div>
<div class="channels">
<channel-strip v-for="(instrument, index) in activeSong.instruments"
:key="`channel_${index}`"
:instrument-index="index"
/>
</div>
</div>
</template>

<script>
import { mapState } from 'vuex';
import ChannelStrip from './components/channel-strip';
import messages from './messages.json';
export default {
i18n: { messages },
components: {
ChannelStrip,
},
computed: {
...mapState({
activeSong: state => state.song.activeSong,
}),
},
};
</script>

<style lang='scss' scoped>
@import '@/styles/_layout.scss';
.mixer {
@include editorComponent();
@include overlay();
height: auto;
}
.title {
margin: $spacing-medium;
}
/* ideal size and above (tablet/desktop) */
$ideal-mixer-width: 895px;
$ideal-mixer-height: 360px;
@media screen and ( min-width: $ideal-mixer-width ) {
.mixer {
top: 50%;
left: 50%;
width: $ideal-mixer-width;
height: $ideal-mixer-height;
margin-left: -$ideal-mixer-width / 2;
margin-top: -$ideal-mixer-height / 2;
}
}
/* small screen / mobile, etc. */
@media screen and ( max-width: $ideal-mixer-width ) {
.mixer {
position: absolute;
height: 100%;
top: 0;
margin-top: 0;
@include verticalScrollOnMobile();
}
}
</style>
3 changes: 2 additions & 1 deletion src/components/song-editor/messages.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"en-US": {
"instrumentEditor": "Instrument editor"
"instrumentEditor": "Instrument editor",
"mixer": "Mixer"
}
}
8 changes: 7 additions & 1 deletion src/components/song-editor/song-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
id="instrumentEditBtn"
@click="handleInstrumentEditorClick"
></button>
<button v-t="'mixer'"
@click="handleMixerClick"
></button>
</section>
</template>

Expand All @@ -50,7 +53,10 @@ export default {
]),
handleInstrumentEditorClick() {
this.openModal(ModalWindows.INSTRUMENT_EDITOR);
}
},
handleMixerClick() {
this.openModal(ModalWindows.MIXER);
},
}
};
</script>
Expand Down

0 comments on commit 90023a0

Please sign in to comment.