Anyone got any experience of using the CAMD library?
I've got myself a nice MT-32 and a MIDI stream so it would be nice to put the two together
I can see the 'official' library on AmiNet and someone also did an open source version.
Neither version includes any proto type header files which is annoying, I want plug-and-play dammit!
I could generate my own header file but that would be hard and time consuming
http://aminet.net/package/mus/edit/camd
CAMD also looks very complicated to use, not sure why
Here is some sample code that I found (
http://wiki.amigaos.net/wiki/Camd_Library)
PHP Code:
/*
** MidiThru.c
** Creates a link between named clusters
** 3/24/2012 Lyle Hazelwood
*/
#include <proto/camd.h>
#include <proto/dos.h>
#include <proto/exec.h>
#include <stdlib.h>
void bailout(char *); // our cleanup
struct Library *CamdBase = NULL;
struct CamdIFace *ICamd = NULL;
// these don't have to be global,
// but it makes cleanup easier.
struct MidiNode *ournode = NULL;
struct MidiLink *fromLink = NULL, *toLink = NULL;
int8 midisig = -1;
int main(int argc, char **argv)
{
MidiMsg mmsg;
uint32 signal;
BOOL alive = TRUE;
if(argc != 3)
{
IDOS->Printf("Shell usage %s from to\n", argv[0]);
IDOS->Printf("where from and to are named MIDI clusters\n");
return(1);
}
// We open camd.library and get the main interface
CamdBase = IExec->OpenLibrary("camd.library", 36L);
if(NULL == CamdBase) bailout("Can't open camd.library");
ICamd = (struct CamdIFace *)IExec->GetInterface(CamdBase, "main", 1, NULL);
if(NULL == ICamd) bailout("Can't get CAMD interface");
// camd will use this signal when we have incoming MIDI
midisig = IExec->AllocSignal(-1);
if(-1 == midisig) bailout("Cant get a signal");
// We create our MidiNode here, requesting buffers as desired
ournode = ICamd->CreateMidi(MIDI_MsgQueue, 2048L,
MIDI_SysExSize, 10000L,
MIDI_RecvSignal, midisig,
TAG_END);
if(NULL == ournode) bailout("Can't Create MidiNode");
// This is our input stream of MIDI messages
fromLink = ICamd->AddMidiLink(ournode, MLTYPE_Receiver,
MLINK_Location,argv[1],
TAG_END);
if(NULL == fromLink) bailout("Can't Add Input Link");
// and our output stream
toLink = ICamd->AddMidiLink(ournode, MLTYPE_Sender,
MLINK_Location, argv[2],
TAG_END);
if(NULL == toLink) bailout("Can't Add Output Link");
IDOS->Printf("Success Linking %s to %s\n",argv[1],argv[2]);
// Now with all the setup finished, we copy incoming
// MIDI messages back out again
while(alive)
{ // this will run until a BREAK is received (Ctrl-C)
signal = IExec->Wait(SIGBREAKF_CTRL_C | 1L << midisig);
if(signal & SIGBREAKF_CTRL_C)
alive = FALSE;
while(ICamd->GetMidi(ournode, &mmsg))
{ // Every message we get...
ICamd->PutMidi(toLink, mmsg.mm_Msg); // we send back out.
}
}
IDOS->Printf("MIDI Link from %s to %s is broken\n",argv[1],argv[2]);
bailout(NULL); // return all resources.
return (0);
}
void bailout(char *reason)
{
if(reason)
{
IDOS->Printf("%s\n",reason);
}
ICamd->RemoveMidiLink(toLink);
ICamd->RemoveMidiLink(fromLink);
ICamd->DeleteMidi(ournode);
IExec->FreeSignal(midisig);
IExec->DropInterface((struct Interface *)ICamd);
IExec->CloseLibrary(CamdBase);
if(reason) exit(-1);
}
I just want to pass some MIDI data through my serial port to my MIDI interface, nothing fancy. Maybe CAMD isn't the best solution, anyone got any better ideas?