ABC to Animation for Concertina

Last Updated or created 2023-01-05

I want to take simple ABC Music notation tunes and convert these to animations which shows you which keys to press and to push or pull.

This is a work in progress.
Script is using ImageMagick and ffmpeg

I started this in bash, and i should rewrite this in python.

Bash script which generates the images

#!/bin/bash
convert -size 800x600 canvas:white white.png
x=55
y=55
draw=""
for xx in $(seq 1 6); do
for yy in $(seq 1 5); do
	startx=$(( $x * $xx + 100))
	starty=$(( $y * $yy + 200))
if [ $xx -gt 3 ] ; then startx=$(($startx + 200)) ;fi
draw="$draw  -draw \"circle $startx,$starty $(( $startx - 10)),$(( $starty - 10 ))\""
done
done
echo convert $draw white.png          draw_circle.png | bash

for xx in $(seq 1 6); do
for yy in $(seq 1 5); do
        startx=$(( $x * $xx + 100))
        starty=$(( $y * $yy + 200))
if [ $xx -gt 3 ] ; then startx=$(($startx + 200)) ;fi
convert -fill white -stroke black $draw  -draw "circle $startx,$starty $(( $startx - 10)),$(( $starty - 10 ))" draw_circle.png $xx-$yy.png
convert  -draw "rectangle 300,50 500,100"  $xx-$yy.png push-$xx-$yy.png
convert  -draw "rectangle 150,50 650,100"  $xx-$yy.png pull-$xx-$yy.png
done
done

Example movie generated using random notes/length pause

for f in $(seq 1 50) ; do
pushpull=$(shuf -n1 -e push pull)
row=$(shuf -n1 -e 1 2 2 2 2 2 3 4 4 5 5 5 6)
col=$(shuf -n1 -e 1 1 1 2 2 3)
pauze=$(shuf -n1 -e 0 0 0 0 0 0 0 0 1 )
length=$(shuf -n1 -e 1 1 1 1 2 2 3 4)
file="$pushpull-$row-$col.png"
if [ $pauze == "1" ]; then
file="draw_circle.png"
fi
for f in $(seq 1 $lenght) ; do
echo "file $file"
echo "duration 0.5"
done
done

list to mp4

ffmpeg -f concat -i list  -vf fps=10 -pix_fmt yuv420p test.mp4

Above movie shows left and right hand. Keys to press.
And the bar above represents PULL/PUSH

Todo/In progress:

  • abc parser ( started )
  • Push/Pull as text in above movie also note to play??
  • Rewrite to python
Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *