Thread: Camd midi c++
View Single Post
Old 05 April 2015, 03:12   #1
NovaCoder
Registered User
 
NovaCoder's Avatar
 
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,406
Camd midi c++

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 argcchar **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 == CamdBasebailout("Can't open camd.library");
 
    
ICamd = (struct CamdIFace *)IExec->GetInterface(CamdBase"main"1NULL);
    if(
NULL == ICamdbailout("Can't get CAMD interface");
 
    
// camd will use this signal when we have incoming MIDI
    
midisig IExec->AllocSignal(-1);
    if(-
== midisigbailout("Cant get a signal");
 
    
// We create our MidiNode here, requesting buffers as desired
    
ournode ICamd->CreateMidi(MIDI_MsgQueue2048L,
        
MIDI_SysExSize10000L,
        
MIDI_RecvSignalmidisig,
        
TAG_END);
    if(
NULL == ournodebailout("Can't Create MidiNode");
 
    
// This is our input stream of MIDI messages
    
fromLink ICamd->AddMidiLink(ournodeMLTYPE_Receiver,
        
MLINK_Location,argv[1],
        
TAG_END);
    if(
NULL == fromLinkbailout("Can't Add Input Link");
 
    
// and our output stream
    
toLink ICamd->AddMidiLink(ournodeMLTYPE_Sender
        
MLINK_Locationargv[2],
        
TAG_END);
    if(
NULL == toLinkbailout("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(toLinkmmsg.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?
NovaCoder is offline  
 
Page generated in 0.04447 seconds with 11 queries