Le menu
À retenir
Outils
- Convertisseur de code source en HTML
- Générateur de lien en (x)HTML
- Traduction Français-Esperanto online
Vie pratique
Portfolio
Présidentielles
Culture
- Respect des droits d'auteurs et droits voisins — Refus des Mesures Techniques de Protection (MTP)
- Licence globale : finalement je suis contre...
- Lettre à la SACEM : Réaction par rapport au projet de loi DADVSI
- Reprenons en main la culture !
- Gestion Numérique des droits (DRM) : une question de confiance
- Gestion Numérique des droits (DRM) : une question de confiance (2)
Archives
- Septembre 2008
- Aout 2008
- Juillet 2008
- Juin 2008
- Mai 2008
- Avril 2008
- Mars 2008
- Février 2008
- Janvier 2008
- Décembre 2007
- Novembre 2007
- Octobre 2007
- Septembre 2007
- Aout 2007
- Juillet 2007
- Juin 2007
- Mai 2007
- Avril 2007
- Mars 2007
- Février 2007
- Janvier 2007
- Décembre 2006
- Novembre 2006
- Octobre 2006
- Septembre 2006
- Aout 2006
- Juillet 2006
- Juin 2006
- Mai 2006
- Avril 2006
- Mars 2006
- Février 2006
- Janvier 2006
- Décembre 2005
- Novembre 2005
- Octobre 2005
- Septembre 2005
- Aout 2005
- Juillet 2005
- Juin 2005
- Mai 2005
- Avril 2005
- Mars 2005
- Février 2005
- Janvier 2005
- Décembre 2004
- Novembre 2004
- Octobre 2004
Spornikethon
- Mes créations vous plaisent ?
- Vous voulez me soutenir financièrement ?
- Cliquez sur un des boutons ci-dessous selon le montant du dons.
- Merci !
Rouleaux de blogs
Mes préférés
Les amis
- Les bla-blas de Chibi
- Lysel
- Orpheelin
- Nae-chan in Psycholand
- Circée
- Faery Book
- Les bijoux de Hime-Decco
Divers
Mes liens
- Non à la brevetabilité des logiciels en Europe
- Promotion d'artistes proposant de la musique légale et gratuite à télécharger
- Associations pour le Maintien d’une Agriculture Paysanne
- La Bible
- Wikipédia
- Le Trésor de la Langue Française Informatisé
- Liste prête à l'emploi pour Adblock
- Partitions pour guitare classique
- Forum francophone pour les collectionneurs et créateurs de poupées
- Association sportive et culturelle du 13ème arrondissement
Bombardement Google
S4MFR : partie 1
Le 01 Décembre 2004 à 12:12
Naissance d'un projet
Dans le cadre de ma démarche pour améliorer mes compétence de développeur C/C++ sous Linux, j'ai besoin d'un petit projet pour commencer à mettre en pratique les Autotools de GNU. Or il se trouve que j'ai créé des fichiers MIDI avec le Logiciel Big Boss de Rythm'n Soft, et la reprise de ces fichiers dans un autre séquenceur n'est pas satisfaisante (mauvaise affectation des instruments par exemple). Je suppose que cela est liée au méchanisme des pistes virtuelles du logiciel qui permet d'avoir plusieur version d'une même piste.
Je vais donc écrire une petite librairie de fonction permettant d'extraire les données d'un fichier MIDI standard, le but étant ensuite d'écrire avec cette librairie un programme qui à partir d'un fichier MIDI génère un rapport en HTML pour voir ce qui ce passe
.
Ressources
- L'organisation MIDI Manufacturers Association
- Le site central pour les références (payantes)
- Standard MIDI Files 1.0 July, 1988
- Une autre description du format MIDI
- Wotsit
- Un site permettant de trouver les spécifications de la plupart des formats de fichier
Annexes
Pour retrouver rapidement les infos, je recopie ci-après l'article de Dustin Caldwell sur les fichier midi, trouvé sur Wotsit.
Standard MIDI File Format, par Dustin Caldwell
= 128). A list of most of these commands is in appendix A. Each
command has different parameters and lengths, but the data that follows the
command will have a msb of 0 (less than 128). The exception to this is a meta-
event, which may contain data with a msb of 1. However, meta-events require a
length parameter which alleviates confusion.
One subtlety which can cause confusion is running mode. This is where
the actual midi command is omitted, and the last midi command issued is
assumed. This means that the midi event will consist of a delta-time and the
parameters that would go to the command if it were included.
4. Conclusion
If this explanation has only served to confuse the issue more, the
appendices contain examples which may help clarify the issue. Also, 2
utilities and a graphic file should have been included with this document:
DEC.EXE - This utility converts a binary file (like .MID) to a tab-delimited
text file containing the decimal equivalents of each byte.
REC.EXE - This utility converts a tab-delimited text file of decimal values
into a binary file in which each byte corresponds to one of the decimal
values.
MIDINOTE.PS - This is the postscript form of a page showing note numbers with
a keyboard and with the standard grand staff.
Appendix A
1. MIDI Event Commands
Each command byte has 2 parts. The left nybble (4 bits) contains the actual
command, and the right nybble contains the midi channel number on which the
command will be executed. There are 16 midi channels, and 8 midi commands (the
command nybble must have a msb of 1).
In the following table, x indicates the midi channel number. Note that all
data bytes will be <128 (msb set to 0).
Hex Binary Data Description
8x 1000xxxx nn vv Note off (key is released)
nn=note number
vv=velocity
9x 1001xxxx nn vv Note on (key is pressed)
nn=note number
vv=velocity
Ax 1010xxxx nn vv Key after-touch
nn=note number
vv=velocity
Bx 1011xxxx cc vv Control Change
cc=controller number
vv=new value
Cx 1100xxxx pp Program (patch) change
pp=new program number
Dx 1101xxxx cc Channel after-touch
cc=channel number
Ex 1110xxxx bb tt Pitch wheel change (2000H is normal or no
change)
bb=bottom (least sig) 7 bits of value
tt=top (most sig) 7 bits of value
The following table lists meta-events which have no midi channel number. They
are of the format:
FF xx nn dd
All meta-events start with FF followed by the command (xx), the length, or
number of bytes that will contain data (nn), and the actual data (dd).
Hex Binary Data Description
00 00000000 nn ssss Sets the track's sequence number.
nn=02 (length of 2-byte sequence number)
ssss=sequence number
01 00000001 nn tt .. Text event- any text you want.
nn=length in bytes of text
tt=text characters
02 00000010 nn tt .. Same as text event, but used for
copyright info.
nn tt=same as text event
03 00000011 nn tt .. Sequence or Track name
nn tt=same as text event
04 00000100 nn tt .. Track instrument name
nn tt=same as text event
05 00000101 nn tt .. Lyric
nn tt=same as text event
06 00000110 nn tt .. Marker
nn tt=same as text event
07 00000111 nn tt .. Cue point
nn tt=same as text event
2F 00101111 00 This event must come at the end of each
track
51 01010001 03 tttttt Set tempo
tttttt=microseconds/quarter note
58 01011000 04 nn dd ccbb Time Signature
nn=numerator of time sig.
dd=denominator of time sig. 2=quarter
3=eighth, etc.
cc=number of ticks in metronome click
bb=number of 32nd notes to the quarter
note
59 01011001 02 sf mi Key signature
sf=sharps/flats (-7=7 flats, 0=key of C,
7=7 sharps)
mi=major/minor (0=major, 1=minor)
7F 01111111 xx dd .. Sequencer specific information
xx=number of bytes to be sent
dd=data
The following table lists system messages which control the entire system.
These have no midi channel number. (these will generally only apply to
controlling a midi keyboard, etc.)
Hex Binary Data Description
F8 11111000 Timing clock used when synchronization is
required.
FA 11111010 Start current sequence
FB 11111011 Continue a stopped sequence where left
off
FC 11111100 Stop a sequence
The following table lists the numbers corresponding to notes for use in note
on and note off commands.
Octave|| Note Numbers
# ||
|| C | C# | D | D# | E | F | F# | G | G# | A | A# | B
-----------------------------------------------------------------------------
0 || 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11
1 || 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23
2 || 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35
3 || 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47
4 || 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59
5 || 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71
6 || 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83
7 || 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95
8 || 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107
9 || 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119
10 || 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 |
BIBLIOGRAPHY
"MIDI Systems and Control" Francis Rumsey 1990 Focal Press
"MIDI and Sound Book for the Atari ST" Bernd Enders and Wolfgang Klemme
1989 M&T Publishing, Inc.
MIDI file specs and general MIDI specs were also obtained by sending e-mail
to LISTSERV@AUVM.AMERICAN.EDU with the phrase GET MIDISPEC PACKAGE
in the message.
------------------------------- DEC.CPP ------------------------------------
/* file dec.cpp
by Dustin Caldwell (dustin@gse.utah.edu)
*/
#include
#include
#include
void helpdoc();
main()
{
FILE *fp;
unsigned char ch, c;
if((fp=fopen(_argv[1], "rb"))==NULL) /* open file to read */
{
printf("cannot open file %sn",_argv[1]);
helpdoc();
exit(-1);
}
c=0;
ch=fgetc(fp);
while(!feof(fp)) /* loop for whole file */
{
printf("%ut", ch); /* print every byte's decimal equiv. */
c++;
if(c>8) /* print 8 numbers to a line */
{
c=0;
printf("n");
}
ch=fgetc(fp);
}
fclose(fp); /* close up */
}
void helpdoc() /* print help message */
{
printf("n Binary File Decodernn");
printf("n Syntax: dec binary_file_namenn");
printf("by Dustin Caldwell (dustin@gse.utah.edu)nn");
printf("This is a filter program that reads a binary filen");
printf("and prints the decimal equivalent of each byten");
printf("tab-separated. This is mostly useful when piped n");
printf("into another file to be edited manually. eg:nn");
printf("c:>dec sonata3.mid > son3.txtnn");
printf("This will create a file called son3.txt which cann");
printf("be edited with any ascii editor. nn");
printf("(rec.exe may also be useful, as it reencodes the n");
printf("ascii text file).nn");
printf("Have Fun!!n");
}
---------------------------- REC.CPP ----------------------------------
/* File rec.cpp
by Dustin Caldwell (dustin@gse.utah.edu)
*/
#include
#include
#include
#include
void helpdoc();
main()
{
FILE *rfp, *wfp;
unsigned char ch, c;
char s[20];
if((rfp=fopen(_argv[1], "r"))==NULL) /* open the read file */
{
printf("cannot open file %s n",_argv[1]);
helpdoc();
exit(-1);
}
if((wfp=fopen(_argv[2], "wb"))==NULL) /* open the write file */
{
printf("cannot open file %s n",_argv[1]);
helpdoc();
exit(-1);
}
c=0;
ch=fgetc(rfp);
while(!feof(rfp)) /* loop for whole file */
{
if(isalnum(ch)) /* only 'see' valid ascii chars */
{
c=0;
while(isdigit(ch)) /* only use decimal digits (0-9) */
{
s[c]=ch; /* build a string containing the number */
c++;
ch=fgetc(rfp);
}
s[c]=NULL; /* must have NULL terminator */
fputc(atoi(s), wfp);/* write the binary equivalent to file */
}
ch=fgetc(rfp); /* loop until next number starts */
}
fclose(rfp); /* close up */
fclose(wfp);
}
void helpdoc() /* print help message */
{
printf("n Text File Encodernn");
printf("n Syntax: rec text_file_name binary_file_namenn");
printf("by Dustin Caldwell (dustin@gse.utah.edu)nn");
printf("This is a program that reads an ascii tab-n");
printf("delimited file and builds a binary file wheren");
printf("each byte of the binary file is one of the decimaln");
printf("digits in the text file.n");
printf(" eg:nn");
printf("c:>rec son3.txt son3.midnn");
printf("(This will create a file called son3.mid which isn");
printf("a valid binary file)nn");
printf("(dec.exe may also be useful, as it decodes binary files)nn");
printf("Have Fun!!n");
}
]]>