Most sound apps use AHI to handle the audio generation. Documents and information can be found here.
Since version 4, AHI can be opened in high level(device) or low level(function) mode, depending on how much control you want over the playback. There are plenty of documents at the site link above.
One odd detail that might slow you down: In most OS4 development, it is assumed that you will be using interfaces to access library methods.. i.e. IExec->AllocVecTags() or IIntuition->OpenClass(), unless you specifically declare otherwise by defining __USE_INLINE__ in your code. AHI does the opposite. It assumes that you want inline code unless you specifically define _NO_INLINE in your code.
In all the cases I'm aware of, you'll need to provide some kind of sound data. Whether you read a wav file, or decode an mp3 file, or just create a sine wave mathematically, you'll need something to feed out as audio.
It may be even easier to use Datatypes for sound playback, I have no experience with that.
I have dowloaded the dtplay.c file but when I compile it using CodeBench I get errors. Doest his program compile As-Is or do I need to have some special compiler parameters?
These are the errors....
splat.c:(.text+0x60): undefined reference to `NewDTObject'
splat.c:(.text+0x80): undefined reference to `AllocSignal'
splat.c:(.text+0xa8): undefined reference to `FindTask'
splat.c:(.text+0xe4): undefined reference to `SetAttrs'
splat.c:(.text+0x100): undefined reference to `DoMethod'
splat.c:(.text+0x120): undefined reference to `Wait'
splat.c:(.text+0x134): undefined reference to `FreeSignal'
splat.c:(.text+0x140): undefined reference to `DisposeDTObject'
splat.c:(.text+0x144): undefined reference to `IoErr'
splat.c:(.text+0x158): undefined reference to `PrintFault'
I have dowloaded the dtplay.c file but when I compile it using CodeBench I get errors. Doest his program compile As-Is or do I need to have some special compiler parameters?
These are the errors....
splat.c:(.text+0x60): undefined reference to `NewDTObject'
splat.c:(.text+0x80): undefined reference to `AllocSignal'
splat.c:(.text+0xa8): undefined reference to `FindTask'
splat.c:(.text+0xe4): undefined reference to `SetAttrs'
splat.c:(.text+0x100): undefined reference to `DoMethod'
splat.c:(.text+0x120): undefined reference to `Wait'
splat.c:(.text+0x134): undefined reference to `FreeSignal'
splat.c:(.text+0x140): undefined reference to `DisposeDTObject'
splat.c:(.text+0x144): undefined reference to `IoErr'
splat.c:(.text+0x158): undefined reference to `PrintFault'
You will need to add -D__USE_INLINE__ to the compiler parameters.
No differences except that when its in command line mode its easy to works with makefiles and many sourcefiles, in compare with writing #define __USE_INLINE__ all the time, or add it to some include files (which you will somethere forget to include, and everything will fails, and you will think that __USE_INLINE__ is used, but its not). I.e. command line way imho better.
MIDI files are a bit trickier. They contain performance data, but no instruments.
If the user has attached MIDI equipment, then a program like CAMDPlay can do the job.
If there is no external MIDI gear, then CAMDPlay can use SoftSyn instead, but that is still in Beta.
There is a single app that can replace both. It is called "TiMIDIty", there are a few different versions available. TiMIDIty can also convert a MIDI file into a big sample, so that takes you back to "How to play a sound sample" instead.
Writing a MIDI player yourself can be done, but support of all the details can get involved.
Writing a Software Synthesizer takes a LOT of time and effort, it is NOT a trivial task.
Yep, via SDL_Mixer. But it is requires external MIDI player called Timidity (on os4depot too). In general just type in google "use the SDL to play midi files" , and firt 5 links will give an answers.
Most sound apps use AHI to handle the audio generation. Documents and information can be found here.
Since version 4, AHI can be opened in high level(device) or low level(function) mode, depending on how much control you want over the playback. There are plenty of documents at the site link above.
One odd detail that might slow you down: In most OS4 development, it is assumed that you will be using interfaces to access library methods.. i.e. IExec->AllocVecTags() or IIntuition->OpenClass(), unless you specifically declare otherwise by defining __USE_INLINE__ in your code. AHI does the opposite. It assumes that you want inline code unless you specifically define _NO_INLINE in your code.
In all the cases I'm aware of, you'll need to provide some kind of sound data. Whether you read a wav file, or decode an mp3 file, or just create a sine wave mathematically, you'll need something to feed out as audio.
It may be even easier to use Datatypes for sound playback, I have no experience with that.
I hope this gets you a start!
LyleHaze
LyleHaze
http://thomas-rapp.homepage.t-online.de/examples/dtplay.c
http://thomas-rapp.homepage.t-online.de/examples/melody.c
Thank you both, i will try.
I have dowloaded the dtplay.c file but when I compile it using CodeBench I get errors. Doest his program compile As-Is or do I need to have some special compiler parameters?
These are the errors....
splat.c:(.text+0x60): undefined reference to `NewDTObject'
splat.c:(.text+0x80): undefined reference to `AllocSignal'
splat.c:(.text+0xa8): undefined reference to `FindTask'
splat.c:(.text+0xe4): undefined reference to `SetAttrs'
splat.c:(.text+0x100): undefined reference to `DoMethod'
splat.c:(.text+0x120): undefined reference to `Wait'
splat.c:(.text+0x134): undefined reference to `FreeSignal'
splat.c:(.text+0x140): undefined reference to `DisposeDTObject'
splat.c:(.text+0x144): undefined reference to `IoErr'
splat.c:(.text+0x158): undefined reference to `PrintFault'
Thanks!
Just want to extend the question on how to play midi files also.
You will need to add -D__USE_INLINE__ to the compiler parameters.
@salass00
Perfect. Thank you!
Is it better to use the -D__USE_INLINE__ as a compiler parameter, or to add it to the code itself like this:
#define __USE_INLINE__
just curious.....it works both ways....
Thanks!
@AmigaOneFan
No differences except that when its in command line mode its easy to works with makefiles and many sourcefiles, in compare with writing #define __USE_INLINE__ all the time, or add it to some include files (which you will somethere forget to include, and everything will fails, and you will think that __USE_INLINE__ is used, but its not). I.e. command line way imho better.
MIDI files are a bit trickier. They contain performance data, but no instruments.
If the user has attached MIDI equipment, then a program like CAMDPlay can do the job.
If there is no external MIDI gear, then CAMDPlay can use SoftSyn instead, but that is still in Beta.
There is a single app that can replace both. It is called "TiMIDIty", there are a few different versions available. TiMIDIty can also convert a MIDI file into a big sample, so that takes you back to "How to play a sound sample" instead.
Writing a MIDI player yourself can be done, but support of all the details can get involved.
Writing a Software Synthesizer takes a LOT of time and effort, it is NOT a trivial task.
LyleHaze
LyleHaze
Someone told me that it's possible to use the SDL to play midi files, is this correct?
Yep, via SDL_Mixer. But it is requires external MIDI player called Timidity (on os4depot too). In general just type in google "use the SDL to play midi files" , and firt 5 links will give an answers.