-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from glowspace/develop
support for rendering of musicxml externals
- Loading branch information
Showing
25 changed files
with
2,198 additions
and
2,280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace App\Jobs; | ||
|
||
use App\External; | ||
use App\Services\ExternalMusicXmlService; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Foundation\Bus\Dispatchable; | ||
use Illuminate\Queue\InteractsWithQueue; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
|
||
class RenderExternalMusicXml implements ShouldQueue | ||
{ | ||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; | ||
|
||
protected $external_id; | ||
|
||
/** | ||
* Create a new job instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct($external_id) | ||
{ | ||
$this->external_id = $external_id; | ||
} | ||
|
||
/** | ||
* Execute the job. | ||
* | ||
* @return void | ||
*/ | ||
public function handle(ExternalMusicXmlService $mxml_service) | ||
{ | ||
$external = External::find($this->external_id); | ||
$mxml_service->renderExternalMusicXml($external); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace App\Services; | ||
|
||
use App\External; | ||
use Illuminate\Support\Facades\Storage; | ||
|
||
class ExternalMusicXmlService | ||
{ | ||
protected LilypondClientService $ly_service; | ||
protected RenderedScoreService $rs_service; | ||
|
||
public function __construct(LilypondClientService $ly_service, RenderedScoreService $rs_service) | ||
{ | ||
$this->ly_service = $ly_service; | ||
$this->rs_service = $rs_service; | ||
} | ||
|
||
public static function isMediaTypeRenderable(string $media_type) { | ||
return $media_type == 'file/xml' || $media_type == 'file/mxml'; | ||
} | ||
|
||
// is called by RenderExternalMusicXml job | ||
public function renderExternalMusicXml(External $external) | ||
{ | ||
if (!self::isMediaTypeRenderable($external->media_type)) { | ||
logger('ExternalMusicXmlService: Not rendering, expected media type file/xml or file/mxml, but got ' . $external->media_type); | ||
return; | ||
} | ||
|
||
$contents = file_get_contents(Storage::path($external->filepath)); | ||
$data = $this->ly_service->doClientRenderSvgFromXml($contents); | ||
|
||
$this->rs_service->createMusicXmlRenderedScore($external, $data['svg']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.