From cd72350f450fe9578a52d761d6bb65fb7c7dbe56 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Sun, 11 Sep 2022 18:03:59 +0200 Subject: [PATCH] . --- app/Console/Kernel.php | 2 +- app/Jobs/PitchShiftAudio.php | 7 ++++--- resources/js/chords.jquery.js | 29 ++++++++++++++++++++--------- resources/js/player.js | 14 +++++++++----- resources/views/menu.blade.php | 4 ++-- resources/views/song.blade.php | 2 +- 6 files changed, 37 insertions(+), 21 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 5560f32..7fa6570 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -24,7 +24,7 @@ class Kernel extends ConsoleKernel */ protected function schedule(Schedule $schedule) { - $schedule->command('job:dispatch PitchShiftAudio')->hourly(); + $schedule->command('job:dispatchNow PitchShiftAudio')->hourly(); } /** diff --git a/app/Jobs/PitchShiftAudio.php b/app/Jobs/PitchShiftAudio.php index 9b44a42..61d4cfd 100644 --- a/app/Jobs/PitchShiftAudio.php +++ b/app/Jobs/PitchShiftAudio.php @@ -15,7 +15,7 @@ class PitchShiftAudio implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; - public static $pitches=[1 => '+1', 2 => '+2', 3 => '+3', 4 => '+4', 5 => '+5', 6 => '+6', 7 => '-5', 8 => '-4', 9 => '-3', 10 => '-2', 11 => '-1']; + public static $pitches = [1 => '+1', 2 => '+2', 3 => '+3', 4 => '+4', 5 => '+5', 6 => '+6', 7 => '-5', 8 => '-4', 9 => '-3', 10 => '-2', 11 => '-1']; public function handle() { @@ -23,8 +23,7 @@ class PitchShiftAudio implements ShouldQueue DownloadAudioTracks::dispatchSync(); - - foreach (Song::all() as $song) { + foreach (Song::inRandomOrder()->get() as $song) { $tracks = $song->getAudioTracks(); foreach ($tracks as $track) { $mp3 = $track['path']; @@ -56,6 +55,8 @@ class PitchShiftAudio implements ShouldQueue if (!file_exists($pm)) { $ff = new CommandLine('ffmpeg'); $ff->setTimeout(300); + $ff->setArg('y'); + $ff->setManualArg('-nostdin'); $ff->setArg('i', $pw); $ff->setManualArg('-ab 320k'); $ff->setArg(null, $pm); diff --git a/resources/js/chords.jquery.js b/resources/js/chords.jquery.js index e5f6648..da5291e 100644 --- a/resources/js/chords.jquery.js +++ b/resources/js/chords.jquery.js @@ -1,9 +1,11 @@ -window.tones = ['C', 'C♯', 'D', 'E♭', 'E', 'F', 'F♯', 'G', 'G♯', 'A', 'B♭', 'B']; +window.tones = ['C', 'C♯', 'D', 'D♯', 'E', 'F', 'F♯', 'G', 'G♯', 'A', 'A♯', 'B']; +window.btones = ['C', 'D♭', 'D', 'E♭', 'E', 'F', 'G♭', 'G', 'A♭', 'A', 'B♭', 'B']; (function ($) { function JQchords(element) { this.element = element; this.chordOffset = 0; + this.base = parseInt($(element).data('tone')); this.init(); } @@ -14,6 +16,7 @@ window.tones = ['C', 'C♯', 'D', 'E♭', 'E', 'F', 'F♯', 'G', 'G♯', 'A', 'B $this.convertToTable($(this)); }); }, + convertToTable: function (e) { var lines = e.data('chords'); @@ -44,15 +47,17 @@ window.tones = ['C', 'C♯', 'D', 'E♭', 'E', 'F', 'F♯', 'G', 'G♯', 'A', 'B updateChords: function () { var $this = this; + var b = $this.normKey(this.base + this.chordOffset); + console.log(b); this.element.find('span[data-chord]').each(function () { var c = $(this).data('chord'); var res - if(c===null){ - res=''; - }else { + if (c === null) { + res = ''; + } else { var k = $this.normKey(c.key + $this.chordOffset); - res = $($this.showTone(k) + '' + c.symbols + ''); + res = $($this.showTone(k, b) + '' + c.symbols + ''); if (res.find('.alt').length > 0) { $(this).addClass('withalt'); } @@ -62,8 +67,15 @@ window.tones = ['C', 'C♯', 'D', 'E♭', 'E', 'F', 'F♯', 'G', 'G♯', 'A', 'B }); }, - showTone: function (k) { - var s = tones[k]; + showTone: function (k, base) { + if (base === undefined) { + base = 0; + } + var thistones = window.tones; + if ([0, 1, 3, 5, 8, 10].indexOf(base) >= 0) { + thistones = window.btones; + } + var s = thistones[k]; var t = s.substr(0, 1); var res = '' + t; @@ -76,8 +88,7 @@ window.tones = ['C', 'C♯', 'D', 'E♭', 'E', 'F', 'F♯', 'G', 'G♯', 'A', 'B normKey: function (key) { return (key + 12) % 12; - }, - normSymbols: function (s) { + }, normSymbols: function (s) { return s; } }; diff --git a/resources/js/player.js b/resources/js/player.js index d447513..139dd45 100644 --- a/resources/js/player.js +++ b/resources/js/player.js @@ -2,9 +2,7 @@ window.players = {}; $(document).on('change', 'select[data-name="audio"]', function () { - $('li[data-audio]').hide(); - $('li[data-audio="' + $(this).val() + '"]'); - resetPlayers(); + changeAudio(); }); $(document).on('change', 'select.audiotone', function () { @@ -40,13 +38,19 @@ tone = '0'; } var pid = 'player_' + audio + '_' + tone; - console.log(pid); var p = window.players[pid]; - console.log(p); $(p.elements.container).show(); p.play(); return false; }); + function changeAudio() { + $('li[data-audio]').hide(); + $('li[data-audio="' + $('select[data-name="audio"]').val() + '"]').show(); + resetPlayers(); + } + + changeAudio(); + })(jQuery); diff --git a/resources/views/menu.blade.php b/resources/views/menu.blade.php index 341da1a..18d88a6 100644 --- a/resources/views/menu.blade.php +++ b/resources/views/menu.blade.php @@ -101,9 +101,9 @@ src="https://api.qrserver.com/v1/create-qr-code/?size=50x50&data={{rawurlencode('https://songbook.enhydra.fr/'.$collection->slug)}}" style="width: 15px;height:auto;margin:5px 10px 5px 5px;vertical-align: bottom">Share via QR code @if(isset($song)) diff --git a/resources/views/song.blade.php b/resources/views/song.blade.php index feb67de..054978d 100644 --- a/resources/views/song.blade.php +++ b/resources/views/song.blade.php @@ -6,7 +6,7 @@ @section('title', $song->title.' - '.$song->artist.' - '. $collection->name.' Songbook') @section('content') @include('header',['title'=>$song->title,'subtitle'=>$song->artist]) -
+
@foreach($song->lyrics as $part) @php $c=$song->getChordsData($part['part_chords']); -- 2.39.5