Play sound and wave files

12 posts / 0 new
Last post
AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 1 year 8 months ago
Joined: 2012-02-18 19:55
Play sound and wave files
Hello everyone, there is a little code example on how to play wave files or mp3. Moreover, it is possible to play sound tone? Thank you very much
LyleHaze
LyleHaze's picture
Offline
Last seen: 2 years 7 months ago
Joined: 2011-05-26 03:58
Most sound apps use AHI to
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
thomas
thomas's picture
Offline
Last seen: 1 month 1 week ago
Joined: 2011-05-16 14:23
example on how to play wave
example on how to play wave files
http://thomas-rapp.homepage.t-online.de/examples/dtplay.c http://thomas-rapp.homepage.t-online.de/examples/melody.c
AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 1 year 8 months ago
Joined: 2012-02-18 19:55
Thank you both, i will try.
Thank you both, i will try.
AmigaOneFan
AmigaOneFan's picture
Offline
Last seen: 5 years 11 months ago
Joined: 2011-11-14 16:18
I have dowloaded the dtplay.c
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!
AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 1 year 8 months ago
Joined: 2012-02-18 19:55
Just want to extend the
Just want to extend the question on how to play midi files also.
salass00
salass00's picture
Offline
Last seen: 2 months 3 days ago
Joined: 2011-02-03 11:27
I have dowloaded the dtplay.c
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.
AmigaOneFan
AmigaOneFan's picture
Offline
Last seen: 5 years 11 months ago
Joined: 2011-11-14 16:18
@salass00 Perfect. Thank
@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!
kas1e
kas1e's picture
Offline
Last seen: 3 months 3 weeks ago
Joined: 2010-11-30 15:30
@AmigaOneFan No differences
@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.
LyleHaze
LyleHaze's picture
Offline
Last seen: 2 years 7 months ago
Joined: 2011-05-26 03:58
MIDI files are a bit
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
AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 1 year 8 months ago
Joined: 2012-02-18 19:55
Someone told me that it's
Someone told me that it's possible to use the SDL to play midi files, is this correct?
kas1e
kas1e's picture
Offline
Last seen: 3 months 3 weeks ago
Joined: 2010-11-30 15:30
Yep, via SDL_Mixer. But it is
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.
Log in or register to post comments