English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 05 April 2015, 03:12   #1
NovaCoder
Registered User
NovaCoder's Avatar
 
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 3,700
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  
Old 05 April 2015, 03:34   #2
Retrofan
Ruler of the Universe

Retrofan's Avatar
 
Join Date: Mar 2010
Location: Lanzarote/Spain
Posts: 6,068
Maybe you can ask matheussen?

https://github.com/kmatheussen/camd
Retrofan is offline  
Old 05 April 2015, 03:52   #3
NovaCoder
Registered User
NovaCoder's Avatar
 
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 3,700
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

Last edited by NovaCoder; 06 April 2015 at 02:44.
NovaCoder is offline  
Old 06 April 2015, 16:10   #4
Samurai_Crow
Total Chaos forever!

Samurai_Crow's Avatar
 
Join Date: Aug 2007
Location: Ft. Collins, CO USA
Age: 44
Posts: 1,282
Send a message via Yahoo to Samurai_Crow
You might look on the Developer CD. I think the official release version and headers are there.
Samurai_Crow is offline  
Old 07 April 2015, 02:24   #5
NovaCoder
Registered User
NovaCoder's Avatar
 
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 3,700
Thanks, I'll see if I can find the CD on the Net
NovaCoder is offline  
Old 07 April 2015, 13:27   #6
Mad-Matt
Longplayer

Mad-Matt's Avatar
 
Join Date: Jan 2005
Location: Lincoln / UK
Age: 40
Posts: 1,595
Send a message via ICQ to Mad-Matt Send a message via MSN to Mad-Matt
Quote:
Originally Posted by NovaCoder View Post
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.

Last edited by Mad-Matt; 07 April 2015 at 13:36.
Mad-Matt is offline  
Old 08 April 2015, 01:08   #7
NovaCoder
Registered User
NovaCoder's Avatar
 
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 3,700
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!

Last edited by NovaCoder; 15 April 2015 at 02:16.
NovaCoder is offline  
Old 17 April 2015, 15:22   #8
NovaCoder
Registered User
NovaCoder's Avatar
 
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 3,700
OK got it working in ODAMEX

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...

[ Show youtube player ]

Last edited by NovaCoder; 27 April 2015 at 03:56.
NovaCoder is offline  
Old 17 April 2015, 19:20   #9
Retrofan
Ruler of the Universe

Retrofan's Avatar
 
Join Date: Mar 2010
Location: Lanzarote/Spain
Posts: 6,068
Congrats bro! Very impressive
Retrofan is offline  
Old 18 April 2015, 00:39   #10
NovaCoder
Registered User
NovaCoder's Avatar
 
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 3,700
Quote:
Originally Posted by Retrofan View Post
Congrats bro! Very impressive
Thanks, it's nice to finally be able to add MIDI support to my ports
NovaCoder is offline  
Old 18 April 2015, 00:52   #11
Retrofan
Ruler of the Universe

Retrofan's Avatar
 
Join Date: Mar 2010
Location: Lanzarote/Spain
Posts: 6,068
Quote:
Originally Posted by NovaCoder View Post
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?
Retrofan is offline  
Old 18 April 2015, 02:29   #12
NovaCoder
Registered User
NovaCoder's Avatar
 
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 3,700
Quote:
Originally Posted by Retrofan View Post
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.
NovaCoder is offline  
Old 18 April 2015, 02:34   #13
Retrofan
Ruler of the Universe

Retrofan's Avatar
 
Join Date: Mar 2010
Location: Lanzarote/Spain
Posts: 6,068
Quote:
Originally Posted by NovaCoder View Post
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? ! ?
(Translation: Amazing! Is he crazy?, So Cool-Cool-Cool Thanks master!)

Last edited by Retrofan; 18 April 2015 at 15:21.
Retrofan is offline  
Old 18 April 2015, 17:52   #14
Amicol
Registered User

 
Join Date: Dec 2013
Location: Hartlepool / England
Posts: 387
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
Amicol is offline  
Old 19 April 2015, 05:37   #15
NovaCoder
Registered User
NovaCoder's Avatar
 
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 3,700
Cool

No not yet, I'll add Prisma support then do a release!
NovaCoder is offline  
Old 23 April 2015, 18:22   #16
Amicol
Registered User

 
Join Date: Dec 2013
Location: Hartlepool / England
Posts: 387
No worries mate, can't wait!!
Amicol is offline  
Old 24 April 2015, 04:01   #17
NovaCoder
Registered User
NovaCoder's Avatar
 
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 3,700
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.
NovaCoder is offline  
Old 25 April 2015, 04:58   #18
Amicol
Registered User

 
Join Date: Dec 2013
Location: Hartlepool / England
Posts: 387
Quote:
Originally Posted by NovaCoder View Post
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?
Amicol is offline  
Old 25 April 2015, 12:22   #19
NovaCoder
Registered User
NovaCoder's Avatar
 
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 3,700
Quote:
Originally Posted by Amicol View Post
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
NovaCoder is offline  
Old 23 October 2016, 00:19   #20
Retrofan
Ruler of the Universe

Retrofan's Avatar
 
Join Date: Mar 2010
Location: Lanzarote/Spain
Posts: 6,068
Quote:
Originally Posted by NovaCoder View Post
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.
Retrofan is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
wanted: midi interface for A500 (midi out) lost_lemming MarketPlace 1 19 February 2010 14:24
looking for a midi interface... pbareges MarketPlace 2 04 April 2007 14:48
A500 and MIDI pakipaki support.Hardware 4 29 June 2006 00:43
Midi DeAdLy_cOoKiE support.WinUAE 2 07 August 2005 12:23
Looking for a MIDI Rastanking Nostalgia & memories 0 11 July 2005 20:05

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Page generated in 0.11130 seconds with 14 queries