|
From: Chris S. <cps...@ya...> - 2013-12-08 12:47:58
|
I've tried the following:
/* Create a Format 1 MIDI file */
9 fd = MidiFileCreate("output.mid", midifile1, TicksPerQuarterNote, 500);
10 if(fd == NULL) {
11 printf("File could not be created\n");
12 error = MidiGetError();
13 printf("Error: %ld\n", error);
14 return 0;
15 } else if(fd != NULL) {
16
It's producing the following output:
File could not be created
Error: 0
The app is generating a MIDI file but its size is 0 bytes.
Any idea what's going on here?
I'm using OSX 10.9.
Cheers,
Chris
________________________________
From: Dominique Fober <fo...@gr...>
To: Chris Share <cps...@ya...>
Cc: "mid...@li..." <mid...@li...>
Sent: Friday, 29 November 2013 3:09 AM
Subject: Re: [midishare-devel] How to Write Data to a MIDI File
Hi Chris,
You should rather use high level functions (MidiFileWriteTrack) than MidiFileWriteEv (that requires opening a track first etc…).
Sample code is available at https://sourceforge.net/p/midishare/code/ci/master/tree/libraries/midifile/example.c
—
Dominique
Le 26 nov. 2013 à 12:58, Chris Share <cps...@ya...> a écrit :
Hi,
>
>I'd like to use MidiShare to create MIDI files however I'm having problems understanding how to use the API. Here's what I've tried:
>
>#include "midifile.h"
>
>int main(int argc, char* argv[]) {
>
>midiFILE *fd;
>
>/* we first create a new MIDI file using a format 1*/
>if(fd = MidiFileCreate("output.mid", midifile1, TicksPerQuarterNote, 500)) {
>
>/* for the file consistency, the first track */
>/* to write is the tempo map*/
>MidiSeqPtr myTempoMap = MidiNewSeq();
>MidiFileWriteTrack(fd, myTempoMap);
>
>/* write the second track */
>MidiFileNewTrack(fd);
>MidiEvPtr e = MidiNewEv(typeNote);
>if (e) {
>Chan(e) = 0; // channels have numbers from 0 to 15
>Port(e) = 0; // port 0 is Modem port, port 1 is Printer port
>Date(e) = 1000;
>MidiSetField(e, 0, 60); // the pitch
>MidiSetField(e, 1, 80); // the velocity
>MidiSetField(e, 2, 1000); // the duration in milliseconds
>
>MidiFileWriteEv(fd, e);
>
>MidiFreeEv(e);
>}
>
>MidiFileCloseTrack(fd);
>
>/* and we finaly close the file*/
>MidiFileClose(fd);
>}
>
> return 0;
>}
>
>This code is producing a MIDI file however its size is zero bytes. What am I doing wrong here?
>
>Cheers,
>
>Chris
>
>------------------------------------------------------------------------------
>Shape the Mobile Experience: Free Subscription
>Software experts and developers: Be at the forefront of tech innovation.
>Intel(R) Software Adrenaline delivers strategic insight and game-changing
>conversations that shape the rapidly evolving mobile landscape. Sign up now.
>http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
>_______________________________________________
>midishare-devel mailing list
>mid...@li...
>https://lists.sourceforge.net/lists/listinfo/midishare-devel
>
|