]> _ Git - songbook.git/commitdiff
.
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Sun, 11 Sep 2022 16:03:59 +0000 (18:03 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Sun, 11 Sep 2022 16:03:59 +0000 (18:03 +0200)
app/Console/Kernel.php
app/Jobs/PitchShiftAudio.php
resources/js/chords.jquery.js
resources/js/player.js
resources/views/menu.blade.php
resources/views/song.blade.php

index 5560f3251eb5ed2d46b324eaae048633344570c4..7fa65705440350d65c813764b413b8da7ef39526 100644 (file)
@@ -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();
     }
 
     /**
index 9b44a42c5664bca341b46b8b7e01ab7c705b4632..61d4cfd43269c4a1ff8c029cae185450bc0f1d28 100644 (file)
@@ -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);
index e5f6648fc2df8317eda9bea5910686757470d749..da5291e19fcee9bcc571567f91e993a9511ef742 100644 (file)
@@ -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) + '<span class="symbols">' + c.symbols + '</span>');
+                    res = $($this.showTone(k, b) + '<span class="symbols">' + c.symbols + '</span>');
                     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 = '<span class="tone">' + 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;
         }
     };
index d447513af4234b8b2739a78070c3a2e1b24fb6ac..139dd45e873f93fae07099a521dead6b82c8a220 100644 (file)
@@ -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 () {
             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);
index 341da1a6ccadff132d3d5f8e59e58ddd34d5b1c9..18d88a6ed90d3fa557aa7993b6be214f1bc18388 100644 (file)
                         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</span>
                 <ul>
-                    <li style="padding:30px;"><img
+                    <div style="padding: 30px;background-color: #fff;height: 100%"><img
                             src="https://api.qrserver.com/v1/create-qr-code/?size=300x300&data={{rawurlencode('https://songbook.enhydra.fr/'.$collection->slug)}}"
-                            style="width: 100%;height:auto;"></li>
+                            style="width: 100%;height:auto;"></div>
                 </ul>
             </li>
             @if(isset($song))
index feb67de2f76e4d941adbdfe2c074f28de21546da..054978d85ece1d61e15f0073f529bb7937b5f8ed 100644 (file)
@@ -6,7 +6,7 @@
 @section('title', $song->title.' - '.$song->artist.' - '. $collection->name.' Songbook')
 @section('content')
     @include('header',['title'=>$song->title,'subtitle'=>$song->artist])
-    <article class="song">
+    <article class="song" data-tone="{{$song->key}}" data-mode="{{$song->mode}}">
         @foreach($song->lyrics as $part)
             @php
                 $c=$song->getChordsData($part['part_chords']);