On 2021-10-30 12:42 am, Pablo Cordal wrote:
Hi,
Until now, I use WMP to play the midi compiled in lilypond. I have
coolsoft
virtualmidisynth installed with a sf2 of my taste and no problem,
everything works fine.
The problem: WMP blocks the midi file while (and after) it's playing,
so if
I modify something in lilypond and I want to hear it, I have to close
WMP,
then compile, go to the folder and reproduce again.. and I'm composing
so I
do it a LOT of times.
Question: anybody knows a mid player with does not block the file, so
it
loads the file each time for playing it?
I ran into the same issue as you and found the easiest option was to
simply force Windows to kill any open WMP instances within my build
script so I would not have to remember to manually close it first.
Below is what I use with Visual Studio Code as my IDE of choice and
Lilypond running within WSL. The main part you'll be interested in is
right near the beginning of build.sh.
==== .vscode/build.sh ====
#!/usr/bin/env bash
close_wmplayer=1
format=pdf
crop=0
function build {
# NOTE: Windows Media Player locks files it has opened.
# This prevents LilyPond from generating a new MIDI file.
# The workaround is to forcefully close all instances of
# the player to ensure the build process works reliably.
if (( $close_wmplayer == 1)); then
taskkill //im wmplayer.exe 2>/dev/null
close_wmplayer=0
fi
for file in $1; do
args=( -dno-point-and-click )
(( $crop == 1 )) && args+=( -dcrop -dno-print-pages )
case $format in
ps) args+=( --ps ) ;;
pdf) args+=( --pdf ) ;;
png) args+=( -dresolution=300 --png ) ;;
svg) args+=( -dbackend=svg ) ;;
esac
args+=( "$file" )
echo "# wsl lilypond ${args[@]}"
wsl lilypond ${args[@]}
done
}
while :; do
case $1 in
--ps|--ps-crop) format=ps; [[ "$1" =~ -crop$ ]] && crop=1 || crop=0
;;
--pdf|--pdf-crop) format=pdf; [[ "$1" =~ -crop$ ]] && crop=1 ||
crop=0 ;;
--png|--png-crop) format=png; [[ "$1" =~ -crop$ ]] && crop=1 ||
crop=0 ;;
--svg|--svg-crop) format=svg; [[ "$1" =~ -crop$ ]] && crop=1 ||
crop=0 ;;
-?*) printf 'WARN: Unknown option (ignored): %s\n' "$1" >&2 ;;
?*) build $1 ;;
*) break
esac
shift
done
====
==== .vscode/tasks.json ====
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "LilyPond (PS)",
"type": "shell",
"command": ".vscode/build.sh",
"args": [
"--ps",
"${relativeFile}"
],
"group": "build",
"presentation": {
"echo": true,
"reveal": "never",
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": true
},
"problemMatcher": "$gcc"
},
{
"label": "LilyPond (PS, cropped)",
"type": "shell",
"command": ".vscode/build.sh",
"args": [
"--ps-crop",
"${relativeFile}"
],
"group": "build",
"presentation": {
"echo": true,
"reveal": "never",
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": true
},
"problemMatcher": "$gcc"
},
{
"label": "LilyPond (PDF)",
"type": "shell",
"command": ".vscode/build.sh",
"args": [
"--pdf",
"${relativeFile}"
],
"group": "build",
"presentation": {
"echo": true,
"reveal": "never",
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": true
},
"problemMatcher": "$gcc"
},
{
"label": "LilyPond (PDF, cropped)",
"type": "shell",
"command": ".vscode/build.sh",
"args": [
"--pdf-crop",
"${relativeFile}"
],
"group": "build",
"presentation": {
"echo": true,
"reveal": "never",
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": true
},
"problemMatcher": "$gcc"
},
{
"label": "LilyPond (PNG)",
"type": "shell",
"command": ".vscode/build.sh",
"args": [
"--png",
"${relativeFile}"
],
"group": "build",
"presentation": {
"echo": true,
"reveal": "never",
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": true
},
"problemMatcher": "$gcc"
},
{
"label": "LilyPond (PNG, cropped)",
"type": "shell",
"command": ".vscode/build.sh",
"args": [
"--png-crop",
"${relativeFile}"
],
"group": "build",
"presentation": {
"echo": true,
"reveal": "never",
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": true
},
"problemMatcher": "$gcc"
},
{
"label": "LilyPond (SVG)",
"type": "shell",
"command": ".vscode/build.sh",
"args": [
"--svg",
"${relativeFile}"
],
"group": "build",
"presentation": {
"echo": true,
"reveal": "never",
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": true
},
"problemMatcher": "$gcc"
},
{
"label": "LilyPond (SVG, cropped)",
"type": "shell",
"command": ".vscode/build.sh",
"args": [
"--svg-crop",
"${relativeFile}"
],
"group": "build",
"presentation": {
"echo": true,
"reveal": "never",
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": true
},
"problemMatcher": "$gcc"
}
]
}
====
-- Aaron Hill