pouët.net

Go to bottom

Playing sound for Amiga

category: code [glöplog]
Hello Amigans,

I want my next demo production to be able to play "sounds" not decided yet which sort of audio.

I have a couple of questions:

1) Is it possible to call the existing, say for example MOD and AHX, music replayers written in Assembly from within a demo written in C?

2) Any demos using not music but ambient sounds?

Any help is very welcome as usual, thanks, cheers.
added on the 2016-02-17 10:11:44 by AlienTech AlienTech
Quote:
Hello Amigans,

2) Any demos using not music but ambient sounds?


The first demo that comes to mind that uses an ambient soundscape is lux aeterna luceat eis by Ephidrena which is a fabulous demo, i'd also be interested to know of others.

As for your other questions i'm sure some of the elite amiga coders here can help answer them for you :)
added on the 2016-02-17 10:19:06 by keito keito
Playing music in a demo is a very good idea.
You can call assembly routines from C code.
A common alternative to mods are adpcm-compressed wavs.
From the technological point there's not much difference between "music" and "ambient sounds".
added on the 2016-02-17 10:23:42 by hfr hfr
Any source code examples available?
Or tutorial or other resource?
Thanks in advance.
added on the 2016-02-18 13:37:10 by AlienTech AlienTech
Try P61 Player.
It's the best mod player in the town. Happy coding.
added on the 2016-02-18 14:05:06 by ham ham
I would need an example how to setup the audio hardware and then play a sampled sound (IFF, WAV, ...).

Alternatively an example how to call a music replayer (MOD, AHX, ...) written in Assembly from C code would also help me.

I am using C for the demo code with direct programming of the custom chips (no OS).

I hope this helps you to help me thanks :)
added on the 2016-02-19 10:21:27 by AlienTech AlienTech
ham and hellfire already gave the most relevant hints.
ADA has a really good coding board (but seems to be down again at the moment). you can check amigacoding.com for some more links.
but what might help you most is WinUAE Demo Toolchain 5 which provides an example of how to go into hardware hitting mode and play mod-music with P61 from C.
added on the 2016-02-19 10:52:56 by noname noname
Quote:
WinUAE Demo Toolchain 5 which provides an example of how to go into hardware hitting mode and play mod-music with P61 from C.


I couldn' t find the example you mentioned ... :(
added on the 2016-02-19 13:56:38 by AlienTech AlienTech
The code is in the exampledemo directory. Look for "music", "ahx" or "p61" inside the two .s files.

However, no idea if that's the easiest way to get started. You might have to get an understanding of how that whole project works first, but hey, it's probably worth it. :)
Quote:
Look for "music", "ahx" or "p61" inside the two .s files.


Sorry but I don' t see how Assembly code can be called from C from within .s files.

Anyway I am very happy to say I found an excellent repository on GitHub which seems more suitable to my needs.
added on the 2016-02-19 19:37:42 by AlienTech AlienTech
Quote:
Sorry but I don' t see how Assembly code can be called from C from within .s files.

Yes I know, that would probably require you to read some of the code in that project...

Anyway, glad you found an easier way to proceed.
How does the Amiga play audio, anyway? I always figured that you simply specified a start memory address, an end memory address, a frequency, and then simply told Paula "GO!" Can Paula play sounds backwards?

The thing is, can Paula play anything POKEd into a single memory address like white noise or any realtime-programmed noise, or does it have to write it out in a memory range like I described above? Judging by Da Jormas' "Megane Rellu", it needs to write it to memory first.
added on the 2016-02-20 10:17:26 by Foebane72 Foebane72
Quote:
How does the Amiga play audio, anyway? I always figured that you simply specified a start memory address, an end memory address, a frequency, and then simply told Paula "GO!" Can Paula play sounds backwards?


Yes and no.
The normal way of using Paula is via DMA, in which case you can only specify a start address, loop address and frequency divider to control the speed.
Only forward playing is supported.

It is also possible to poke samples directly to the channels with the CPU (in which case it doesn't matter where they come from in memory). The downside here is that it's rather CPU-intensive. The upside is that you can reach higher speeds this way.
DMA is limited to ~28 KHz replay rate. With the CPU you can go over 50 KHz even on a stock A500, I believe.

See here: http://amigadev.elowar.com/read/ADCD_2.1/Hardware_Manual_guide/node00EF.html
The freaky part is that everything is word-related, so you always send 2 samples at a time (with DMA you can only play from even addresses, and only loop to even addresses as well).
added on the 2016-02-20 11:29:11 by Scali Scali
The thing Scali mentions is something I believe many Amiga coders have wondered about, yet I don't know about anyone who have actually tried it.

<amiga sound legend mode>
There is also another method of exceeding the 28Khz. Since the 2 samples are fetched every raster line. Then doubling the vertical resolution makes it possible to play at 56KHz. I saw this in hippo player too.

Then there is the trick of playing at 14 bit quality by having one channel play the low bits of the signal at volume 1 and the other channel play the high bits at volume 64. Then the result should be mixed together and theoretically be 14-bit.
</amiga sound legend mode>

It would be great if someone could actually measure these effects somehow. I don't know what instrument to use to verify. A sampler or oscilloscope or something? When I hear 14-bit vs 8-bit I actually don't hear much difference except the volume is lower on the 14-bit output. The 28KHz vs 56KHz quality difference I also can't really hear that clearly. Maybe because I mostly played some random mods.

So is there some hard evidence? :) Mythbusters where are you?
added on the 2016-02-20 14:50:19 by rloaderro rloaderro
Call to Amiga coders,

I need to replay a MOD / AHX music from within my demo, I am using C with direct access of the custom chips (no OS).

Anyone did it already?
added on the 2017-08-03 15:13:29 by AlienTech AlienTech
Here's a header and a slightly modified source for the player 6.1.11 which can be included in C:
http://amiga.lauri.me.uk/p61/

You need to convert the MOD to a P61 file with the converter found in the release package. Also you need to change the "usecode" value in the player source file to the one shown at the end of the conversion process. This is used for disabling some replayer features for optimal speed I guess.
added on the 2017-08-03 15:42:42 by dodke dodke
Oh I forgot to mention that I use vbcc+vasm so if you use something else the header syntax for setting register parameters might be different.
added on the 2017-08-03 15:44:54 by dodke dodke
Hi dodke and thanks, I saved your link.

I am using the SAS C compiler 6.58.

Do I need any particular setup (timer, interrupt, ...)?
added on the 2017-08-03 16:05:37 by AlienTech AlienTech
There's a setting called p61mode in the source but the default CIA mode should work as is.

For SAS C I think you need to change the header syntax to something like:
Code:extern __asm void P61_Init(register __a0 unsigned char *p61music);
added on the 2017-08-03 16:15:24 by dodke dodke
So all settings are within the replayer source code itself, if I understand well.

THANKS
added on the 2017-08-03 16:22:02 by AlienTech AlienTech
Call to Amiga coders (again),

anyone that got P61 Player to work with SAS C compiler 6.58 ?

Help is very welcome, thanks!

;)
added on the 2018-01-27 16:56:48 by AlienTech AlienTech
Do you get a compilation error or something when you try? I'm not familiar with sasc and use vbcc/vasm/vlink.
added on the 2018-01-28 10:53:54 by rloaderro rloaderro
2 years in and you still haven't figured it out?
added on the 2018-01-28 11:47:31 by noname noname
Maybe try asking in one of the coder sub-forums at EAB as well.
added on the 2018-01-28 13:15:14 by absence absence
@rloaderro

I see that many coders use vasm for the Assembly combined with different C compilers (vbcc, gcc, ...).
I am using SAS/C 6.58 instead which provides both an assembler and a C compiler as well.
I couldn' t get it to assemble at this moment ("asm" command).

@noname

Wow so much smart reply / help from a smart guy!

@absence

Thanks, will check that too.
added on the 2018-01-28 14:43:44 by AlienTech AlienTech

login

Go to top