|
- Forum - iziBasic
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 257
Topic # 1621 |
Use C code in an iziBasic program? |
20/09/2008 @ 19:44 by 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
Answer n° 1 -------- 21/09/2008 @ 20:28 by aldweb
visitor |
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
Answer n° 2 -------- 22/09/2008 @ 20:09 by Ashley
visitor |
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
Answer n° 3 -------- 28/09/2008 @ 19:08 by aldweb
visitor |
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
|
|
|
topic active
topic closed
Sticky
New message -
Correct message
Close topic
Make sticky
|
|