The Mudcat Café TM
Thread #65760   Message #1087306
Posted By: GUEST
06-Jan-04 - 04:27 PM
Thread Name: Tech: A good music writing program?
Subject: RE: Tech: A good music writing program?
As I don't believe in "trade secerets", John, here is the current code I use to extract an abc file from an mysql database, add words from another db field to give W:, possibly transpose and allow for setting both on A4 and letter... before producing a pdf output for a user. I know it could be improved (and this has been hacked when I added things) on but this is doing its job for us.

<?php

header ("Content-type: application/pdf");
$Connection = mysql_connect("connection details which are secret!");
mysql_select_db("songdb");
$SQL = "Select Tune, Lyrics from Song Where SongID=" . $_GET["SongID"];
$result = mysql_query($SQL);
$row = mysql_fetch_array($result);
$abc = "%%pageheight 11in\n"."%%pagewidth 8.5in\n"."%%leftmargin 0.7in\n"."%%rightmargin 0.7in\n";
if ($_GET["paper"]== "a4"){
$abc = "%%pageheight 29.7cm\n"."%%pagewidth 21.0cm\n"."%%leftmargin 1.8cm\n"."%%rightmargin 1.8cm\n";
}
$abc = $abc . $row[0] . "\nW:". str_replace("
", "\nW:",$row[1]);
$abc = "%%wordsspace 20\n%%footer Printed from folkinfo.org. For details about this song please visit http://www.folkinfo.org/songs\n" . $abc;
if (@$_GET["t"]){
        $fp = fopen("demo1.abc", "wb");
        fwrite($fp, $abc);
        fclose($fp);
        $prog = "abc2abc.exe demo1.abc -e -t " . $_GET["t"] . " >demo.abc";
        exec($prog);
        }
else
        {
        $fp = fopen("demo.abc", "wb");
        fwrite($fp, $abc);
        fclose($fp);
        }
        
$prog = "abcm2ps.exe demo.abc -s 0.8 -O ..\gs\gs7.04\bin\out.ps";
exec($prog);
chdir("..\gs\gs7.04\bin");
if ($_GET["paper"]== "a4"){
        $paper = " -sPAPERSIZE=a4";
}
else
        {
        $paper = "";
        }

exec("gswin32c.exe -q -dNOPAUSE" . $paper . " -dBATCH -sDEVICE=pdfwrite -sOutputFile=out.pdf out.ps");
readfile("out.pdf");
?>