-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrttl2mid.php
executable file
·108 lines (97 loc) · 2.73 KB
/
rttl2mid.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
error_reporting(E_ALL);
$PHP_SELF = $_SERVER['PHP_SELF'];
if (isset($_POST['player'])){
$player = $_POST['player'];
$autostart = isset($_POST['autostart']);
$loop = isset($_POST['loop']);
$visible = isset($_POST['visible']);
}else{
$player = 'default';
$autostart = true;
$loop = false;
$visible = true;
}
$inst = isset($_POST['inst'])?$_POST['inst']:0;
$rttl = isset($_POST['rttl'])?$_POST['rttl']:'Beethoven:d=4,o=5,b=250:e6,d#6,e6,d#6,e6,b,d6,c6,2a.,c,e,a,2b.,e,a,b,2c.6,e,e6,d#6,e6,d#6,e6,b,d6,c6,2a.,c,e,a,2b.,e,c6,b,1a';
$plug = isset($_POST['plug'])?$_POST['plug']:'qt';
/****************************************************************************
MIDI CLASS CODE
****************************************************************************/
require('./classes/midi_rttl.class.php');
$midi = new MidiRttl();
$instruments = $midi->getInstrumentList();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Rttl2Midi</title>
<link rel="stylesheet" type="text/css" href="css/midi.css" />
</head>
<body>
<form action="<?=$PHP_SELF?>" method="post">
<div>
<textarea name="rttl" cols="140" rows="2"><?=$rttl?></textarea>
<br /><br />
Use instrument:
<select name="inst">
<?php
for ($i=0;$i<128;$i++){
echo '<option value="'.($i).'"'.($inst==$i?' selected="selected"':'').'>'.$instruments[$i]."</option>\n";
}
?>
</select><br />
<br />
Player:
<select name="player">
<?
$players = array(
'default'=>'Default',
'quicktime'=>'Quicktime',
'crescendo'=>'Crescendo',
'bgsound'=>'IE Win BgSound',
'windowsmedia'=>'Windows Media',
'beatnik'=>'Beatnik',
'mp3_flash'=>'MP3 Flash Player',
'ogg_html5'=>'OGG HTML5 Player'
);
foreach ($players as$k=>$v){
echo '<option value="'.$k.'"'.($player==$k?' selected="selected"':'').'>'.$v."</option>\n";
}
?>
</select>
<br /><br />
Settings:
<?
$settings = array(
'autostart'=>'Autostart',
'loop'=>'Loop',
'visible'=>'Visible'
);
foreach ($settings as $k=>$v){
echo '<input type="checkbox" name="'.$k.'"'.($$k?' checked="checked"':'').' />'.$v."\n";
}
?>
<br /><br />
<input type="submit" value=" send " />
</div>
</form>
<div style="margin-top:20px">
<?php
if (isset($_POST['rttl'])){
$save_dir = 'tmp/';
srand((double)microtime()*1000000);
$file = $save_dir.rand().'.mid';
$midi->importRttl($_POST['rttl'],$inst);
$midi->saveMidFile($file, 0666);
$midi->playMidFile($file,$visible,$autostart,$loop,$player);
?>
<br /><br /><input type="button" name="download" value="Save as SMF (*.mid)" onclick="self.location.href='download.php?f=<?=urlencode($file)?>'" />
<?
}
?>
</div>
</body>
</html>