|
- Forum - iziBasic
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 257
Sujet n° 1621 |
Use C code in an iziBasic program? |
le 20/09/2008 @ 19:44 par Ashley
|
I would like to use the following code in an iziBasic app. How should I do this?
#include <PalmOS.h> #include <SerialMgrOld.h> #include "midi.h"
UInt16 midiSerLib; Err midiSerError;
/*********************************************************************/ /*********************************************************************/ void OpenMidiPort(void) { /* open port */ SysLibFind("Serial Library", &midiSerLib); midiSerError = SerOpen(midiSerLib, 0, 31250); /* delay for half second to allow the port to be set up properly */ SysTaskDelay(SysTicksPerSecond() >> 1); }
/*********************************************************************/ /*********************************************************************/ void CloseMidiPort(void) { /* close the port only if we need to */ if (midiSerError == 0 || midiSerError == serErrAlreadyOpen) SerClose(midiSerLib); }
/*********************************************************************/ /*********************************************************************/ void SendMidi(UInt8 a, UInt8 b, UInt8 c, UInt8 size) { /* MIDI has up to three bytes per message. Size is the number of bytes to send. The value of the unused messages doesnt matter, and i usually give it 0xFF */ Err err = 0; UInt8 midiBuf[3] = {a, b, c};
SerSend(midiSerLib, midiBuf, size, &err); if (err) SerClearErr(midiSerLib); }
/*********************************************************************/ /*********************************************************************/ void MidiPanic(void) { /* super-mega all notes off, adapted after the messages cakewalk sends. */
UInt8 i;
for (i = 0; i < 16; i++) { SendMidi(0xE0 + i, 0x00, 0x40, 3); SendMidi(0xB0 + i, 0x01, 0x00, 3); SendMidi(0xB0 + i, 0x07, 0x7F, 3); SendMidi(0xB0 + i, 0x0A, 0x40, 3); SendMidi(0xB0 + i, 0x40, 0x00, 3); SendMidi(0xB0 + i, 0x42, 0x00, 3); SendMidi(0xB0 + i, 0x43, 0x00, 3); SendMidi(0xB0 + i, 0x79, 0x00, 3); SendMidi(0xB0 + i, 0x7B, 0x00, 3); } }
void OpenMidiPort(void); void CloseMidiPort(void); void SendMidi(UInt8 a, UInt8 b, UInt8 c, UInt8 size); void MidiPanic(void);
|
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 1 -------- le 21/09/2008 @ 20:28 par aldweb
visiteur |
Hello Ashley,
You can very well use the functions provided by this code in an iziBasic application. You will just have a little bit of work to do.
The answer is to use a so-called "PP applet" (see iziBasic's user manual).
This C code will basically have to be translated to a PP code, not forgetting to retrieve those of the API functions calls (from the C headers PalmOS.h, SerialMgrOld.h and midi.h) used in this source code.
Since Pascal is quite close from C, this translation will be very easy (for those used to read C source codes and accustomed to the Pascal structure).
I wish I had some free time and access to a PC in the next days to do the job for you. Do you feel confident doing it yourself?
Cheers, aldweb
|
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 2 -------- le 22/09/2008 @ 20:09 par Ashley
visiteur |
I am not confident about tranlsating this to PP. If you could help that would really useful!
Thanks. Ashley. |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 3 -------- le 28/09/2008 @ 19:08 par aldweb
visiteur |
Hello Ashley,
For a series of reasons, I will not be in the capacity to do the job in the coming 2 months or so... Can you wait that long?
Anyway, drop me the C files by e-mail (including the .h ones) so that I can try to work on this conversion during some spare time...
Cheers, aldweb
|
|
|
sujet actif
sujet clos
Important!
Nouveau message -
Rectifier message
Clôturer sujet
Remonter
|
|