Skip to content

Commit

Permalink
Merge pull request nukeop#296 from charjac/feat.equalizer
Browse files Browse the repository at this point in the history
feat equalizer
  • Loading branch information
nukeop authored Mar 31, 2019
2 parents 3769615 + 3b2a6f3 commit 16c0336
Show file tree
Hide file tree
Showing 30 changed files with 775 additions and 28 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,6 @@ nuclear.json
bundle.electron.js

# Prettier configuration file
.prettierrc
.prettierrc

package-lock.json
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
6 changes: 4 additions & 2 deletions app/App.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React from 'react';
import FontAwesome from 'react-fontawesome';
import Sound from 'react-sound';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { NavLink, withRouter } from 'react-router-dom';
import classnames from 'classnames';
import _ from 'lodash';
import Sound from 'react-sound-html5';

import * as Actions from './actions';
import * as PlayerActions from './actions/player';
import * as PlaylistsActions from './actions/playlists';
Expand Down Expand Up @@ -151,7 +152,8 @@ class App extends React.Component {
{this.renderNavLink('plugins', 'flask', 'Plugins', settings)}
{this.renderNavLink('search', 'search', 'Search Results', settings)}
{this.renderNavLink('settings', 'cogs', 'Settings', settings)}

{this.renderNavLink('equalizer', 'sliders', 'Equalizer', settings)}

<SidebarMenuCategoryHeader>
Collection
</SidebarMenuCategoryHeader>
Expand Down
31 changes: 31 additions & 0 deletions app/actions/equalizer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export const UPDATE_EQUALIZER = 'UPDATE_EQUALIZER';
export const SET_EQUALIZER = 'SET_EQUALIZER';
export const TOGGLE_VISUALIZATION = 'TOGGLE_VISUALIZATION';
export const SET_VISUALIZATION_DATA = 'SET_VISUALIZATION_DATA';

export function updateEqualizer(payload) {
return {
type: UPDATE_EQUALIZER,
payload
};
}

export function setEqualizer(payload) {
return {
type: SET_EQUALIZER,
payload
};
}

export function toggleVisualization() {
return {
type: TOGGLE_VISUALIZATION
};
}

export function setVisualizationData(payload) {
return {
type: SET_VISUALIZATION_DATA,
payload
};
}
2 changes: 1 addition & 1 deletion app/actions/player.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Sound from 'react-sound';
import Sound from 'react-sound-html5';
import { sendPaused, sendPlay } from '../mpris';

export const START_PLAYBACK = 'START_PLAYBACK';
Expand Down
27 changes: 27 additions & 0 deletions app/components/Equalizer/PreAmp/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react';
import PropTypes from 'prop-types';

import styles from './index.scss';

const PreAmp = ({
onChange,
value
}) => (
<input
type='range'
onChange={evt => onChange(Number(evt.target.value))}
value={value}
className={styles.preamp}
min={-10}
max={10}
step={1}
/>
);

PreAmp.propTypes = {
onChange: PropTypes.func.isRequired,
value: PropTypes.number.isRequired
};

export default PreAmp;

9 changes: 9 additions & 0 deletions app/components/Equalizer/PreAmp/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.preamp {
-webkit-appearance: slider-vertical !important;
height: 60%;
margin-top: 30px;
cursor: grab !important;
&:active {
cursor: grabbing !important;
}
}
63 changes: 63 additions & 0 deletions app/components/Equalizer/chart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
function getChartOptions(data) {
return {
type: 'line',
data,
options: {
events: ['mousemove', 'mousedown'],
onHover: (event, chartElement) => {
switch (event.type) {
case 'mousedown':
event.target.style.cursor = chartElement[0] ? 'grabbing' : 'default';
break;
default:
event.target.style.cursor = chartElement[0] ? 'grab' : 'default';
}
},
responsive: true,
legend: {
display: false
},
tooltips: {
enabled: false
},
animation: {
duration: 1000
},
scales: {
xAxes: [{
display: true,
gridLines: {
display: false
},
scaleLabel: {
display: true
}
}],
yAxes: [{
ticks: {
display: false,
min: 0,
max: 20
},
gridLines: {
display: false
},
scaleLabel: {
display: false
}
}]
}
}
};
}

function formatLabels(frequencies) {
return frequencies.map(freq => {
return freq > 999
? `${Math.round(freq / 1000)}KHz`
: `${freq}Hz`;
});
}

export { getChartOptions, formatLabels };

Loading

0 comments on commit 16c0336

Please sign in to comment.