Skip to content

Commit

Permalink
Added a settings for the autoradio smoothness
Browse files Browse the repository at this point in the history
  • Loading branch information
trekiteasy committed Feb 11, 2019
1 parent 0e023d7 commit d188d42
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
10 changes: 10 additions & 0 deletions app/constants/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ module.exports = [
prettyName: 'Notification timeout',
default: 3
},
{
name: 'autoradioCraziness',
category: 'Playback',
type: settingType.NUMBER,
prettyName: 'Autoradio craziness',
default: 10,
min: 1,
max: 100,
unit: ''
},
{
name: 'disableGPU',
category: 'Program settings',
Expand Down
15 changes: 11 additions & 4 deletions app/containers/SoundContainer/autoradio.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ let lastfm = new core.LastFmApi(globals.lastfmApiKey, globals.lastfmApiSecret);
* If set to 1 : autoradio is likely to play different styles of music
* If set to 0.1 : autoradio is quite conservative and will stay in the same style
*/
const AUTORADIO_TRACKS_DEVIATION = 0.15;
let AUTORADIO_TRACKS_DEVIATION = 0.15;

/*
* No maximum
Expand All @@ -31,7 +31,7 @@ const AUTORADIO_TRACKS_DEVIATION = 0.15;
* If set to 1 : autoradio will select next track only based on the current track in queue
* If set to 10 : autoradio will select next track based on the 10 latest tracks in the queue
*/
const AUTORADIO_IMPACTING_TRACK_NUMBER = 10;
let AUTORADIO_IMPACTING_TRACK_NUMBER = 10;

/*
* No maximum
Expand All @@ -43,15 +43,21 @@ const AUTORADIO_IMPACTING_TRACK_NUMBER = 10;
* AUTORADIO_IMPACTING_TRACK_NUMBER * SIMILAR_TRACKS_RESULTS_LIMIT tracks
* The more tracks, the more likely is the style to be changed
*/
const SIMILAR_TRACKS_RESULTS_LIMIT = 10;
let SIMILAR_TRACKS_RESULTS_LIMIT = 10;

/*
* Min = 0 - Max = 1 (0 will only accept the most similar artist / 1 will go further down the list)
* Will determine wether when looking for similar artists we stay close to the current artist
* This is only used in the case we cannot find similar tracks => we fall back to similar artist search
*/
const AUTORADIO_ARTIST_DEVIATION = 0.20;
let AUTORADIO_ARTIST_DEVIATION = 0.20;

function computeParameters (crazinessScore = 10) {
AUTORADIO_ARTIST_DEVIATION = crazinessScore / 100;
SIMILAR_TRACKS_RESULTS_LIMIT = crazinessScore;
AUTORADIO_IMPACTING_TRACK_NUMBER = 101 - crazinessScore;
AUTORADIO_TRACKS_DEVIATION = crazinessScore;
}

let props;
/**
Expand All @@ -64,6 +70,7 @@ let props;
export function addAutoradioTrackToQueue (callProps) {
props = callProps;
let currentSong = props.queue.queueItems[props.queue.currentSong];
computeParameters(props.settings.autoradioCraziness);

return getSimilarTracksToQueue(AUTORADIO_IMPACTING_TRACK_NUMBER)
.then(track => {
Expand Down

0 comments on commit d188d42

Please sign in to comment.