English Amiga Board

English Amiga Board (https://eab.abime.net/index.php)
-   Coders. C/C++ (https://eab.abime.net/forumdisplay.php?f=118)
-   -   Camd midi c++ (https://eab.abime.net/showthread.php?t=77732)

NovaCoder 05 April 2015 03:12

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 :p

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 :guru

http://aminet.net/package/mus/edit/camd

CAMD also looks very complicated to use, not sure why :confused

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?

Retrofan 05 April 2015 03:34

Maybe you can ask matheussen?

https://github.com/kmatheussen/camd

NovaCoder 05 April 2015 03:52

Yep, just did...thanks :)

Update: I'm now thinking it will be easier for me to just open the serial device and pass my MIDI data to it directly (and skip CAMD)

http://www.soundonsound.com/sos/1995...miganotes.html

Samurai_Crow 06 April 2015 16:10

You might look on the Developer CD. I think the official release version and headers are there.

NovaCoder 07 April 2015 02:24

Thanks, I'll see if I can find the CD on the Net :)

Mad-Matt 07 April 2015 13:27

Quote:

Originally Posted by NovaCoder (Post 1013502)
Yep, just did...thanks :)

Update: I'm now thinking it will be easier for me to just open the serial device and pass my MIDI data to it directly (and skip CAMD)

http://www.soundonsound.com/sos/1995...miganotes.html

I would ask that you try to stick with camd as it would allow those without midi hardware to have music through softsynth as well. SimonII could have done with having camd support when it was released.

I added the files from the dev cd to the zone if they can help.

NovaCoder 08 April 2015 01:08

Thanks and thanks :)

Yep, I'll try with camd

Update:

I had to create my own header file for gcc in the end, I'll upload my generated header here for the future generations ;)

It kind of works with DOOM but doesn't sound quite right, I think it's some kind of timing issue. I can't tell if it's a problem with the data being supplied to the library or if I'm just using it wrong.

The other option is to just read a midi file myself but after looking at the code examples it seems ridiculously complicated.

Instead of a nice a simple
PHP Code:

camd->parseMidi(FILE *filename); 

or even a
PHP Code:

camd->parseMidi(byte *data); 

It seems to need to run in a separate thread and constantly adjust the timing of the file (tempo).....painful!

NovaCoder 17 April 2015 15:22

OK got it working in ODAMEX :xmas

The problems I was having using the game to load and play a MIDI file was to do with priority...just not workable unless it runs in it's own thread.

So my solution for ODAMEX was to create a separate thread and read in the MIDI file, this seems to work fine.

I'm just uploading a video now...

https://www.youtube.com/watch?v=ShVvAVELTQM

Retrofan 17 April 2015 19:20

Congrats bro! Very impressive :)

NovaCoder 18 April 2015 00:39

Quote:

Originally Posted by Retrofan (Post 1015358)
Congrats bro! Very impressive :)

Thanks, it's nice to finally be able to add MIDI support to my ports :)

Retrofan 18 April 2015 00:52

Quote:

Originally Posted by NovaCoder (Post 1015386)
Thanks, it's nice to finally be able to add MIDI support to my ports :)

Do you think that leaving the music for the Roland -so improved a lot- then the CPU relieves some resources to improve speed with graphics, or is it "only" a benefit for the music?

NovaCoder 18 April 2015 02:29

Quote:

Originally Posted by Retrofan (Post 1015387)
Do you think that leaving the music for the Roland -so improved a lot- then the CPU relieves some resources to improve speed with graphics, or is it "only" a benefit for the music?

Yes for sure, not only does it sound much better than emulated MIDI it also has very little load on the CPU.

This should mean that ScummVM with MIDI music will run a bit faster than when you try and emulate MIDI.

Retrofan 18 April 2015 02:34

Quote:

Originally Posted by NovaCoder (Post 1015395)
Yes for sure, not only does it sound much better than emulated MIDI it also has very little load on the CPU.

This should mean that ScummVM with MIDI music will run a bit faster than when you try and emulate MIDI.

What can I say? :shocked! :nuts? :cool:cool:cool :bowdown
(Translation: Amazing! Is he crazy?, So Cool-Cool-Cool Thanks master!)

Amicol 18 April 2015 17:52

Yeh! I'm getting excited, might just dig my Amiga back out of the cupboard!!

Great work Nova, is the midi Odamex available for download? I'd love to try it with my SC55 :D

NovaCoder 19 April 2015 05:37

Cool :)

No not yet, I'll add Prisma support then do a release!

Amicol 23 April 2015 18:22

No worries mate, can't wait!!

NovaCoder 24 April 2015 04:01

I'm porting the latest version of ODAMEX (0.7) at the same time so it will probably take me another couple of weeks.

:)

The best thing about this CAMD knowledge is that I can now begin adding real MIDI (and Prisma) support to a whole load of my earlier ports like Wolfy, Descent and Duke Nukem.

Amicol 25 April 2015 04:58

Quote:

Originally Posted by NovaCoder (Post 1016360)
The best thing about this CAMD knowledge is that I can now begin adding real MIDI (and Prisma) support to a whole load of my earlier ports like Wolfy, Descent and Duke Nukem.

Didn't even know you'd ported Descent! Wow, wouldn't have thought it possible on the humble Amiga! Will have to check it out. ;)


Does this also open up the possibility of real MIDI in ScummVM?

NovaCoder 25 April 2015 12:22

Quote:

Originally Posted by Amicol (Post 1016550)
Didn't even know you'd ported Descent! Wow, wouldn't have thought it possible on the humble Amiga! Will have to check it out. ;)


Does this also open up the possibility of real MIDI in ScummVM?

Yep :spin

Retrofan 23 October 2016 00:19

Quote:

Originally Posted by NovaCoder (Post 1016360)
I'm porting the latest version of ODAMEX (0.7) at the same time so it will probably take me another couple of weeks.

:)

The best thing about this CAMD knowledge is that I can now begin adding real MIDI (and Prisma) support to a whole load of my earlier ports like Wolfy, Descent and Duke Nukem.

Nova can I try something you've made with the Prisma? I don't find it, sorry.

Thanks.


All times are GMT +2. The time now is 01:31.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.

Page generated in 0.04954 seconds with 11 queries