gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Sound:what's the difference between 'Manual' and 'One-Shot'?

#154771 - sverx - Mon Apr 21, 2008 4:06 pm

While I'm still stuck with the RTC (as you can see here ... ) I took a pause and I went back to the sound argument.

Short. The question is: what's the difference between the different sample repeat modes? Because gbatek says that bits 27-28 of the channel control register (SOUNDxCNT) have these meaning:

Quote:
Bit27-28 Repeat Mode (0=Manual, 1=Loop Infinite, 2=One-Shot, 3=Prohibited)


and in the libnds file arm7/audio.h there are 2 defines:

Code:
#define SOUND_REPEAT    BIT(27)
#define SOUND_ONE_SHOT  BIT(28)


... well, of course I understand the 'repeat' mode, and I already used it... what I really can't understand is: what's the difference between Manual ( 0b00 ) and One-Shot ( 0b10 ) ?

TIA :)

#154788 - Cydrak - Mon Apr 21, 2008 7:12 pm

(Ahh, GBAtek, ever so helpful with your terminology.. :b)

These would be better called "GBA" and "instrument" or "looped" modes.

GBA style (mode 0):
Plays until stopped. Not very useful, unless you like listening to your code. ;)
Starting from the source, it'll blow through the whole 0x0000000..0x7FFFFFF region, usually taking a few minutes each time.

Looped instruments (modes 1 and 2):
1) Play SOUNDxPNT (SCHANNEL_REPEAT_POINT) words from the source.
2) Play SOUNDxLEN (SCHANNEL_LENGTH) words from the repeat point.
3) If looping still enabled (mode == 1), repeat from (2).

Phase (1) occurs even if not looping; in that case it's important to zero the restart point.

Changing modes does work mid-sample; eg. a looping channel that was changed to one-shot, will stop next time it hits the end of the loop. Unfortunately, I couldn't make it accept a new length at this time, it seems to only "take" when restarted. So, you can't abuse that to set a loop that ends before the sample does...

(I'll take a look at the RTC shortly: an MP3 alarm was one of my old back-burner projects, and I could swear I'd gotten it working. I used my own API with #defines from the datasheet, however, so it's not obvious what I did differently.)

#154880 - sverx - Tue Apr 22, 2008 8:33 am

Cydrak wrote:
(Ahh, GBAtek, ever so helpful with your terminology.. :b)


sorry, I'm not really good with english so I didn't get what you mean here...

BTW thanks for your reply, it's very clear and useful :)

Cydrak wrote:
These would be better called "GBA" and "instrument" or "looped" modes.
GBA style (mode 0):
Plays until stopped. Not very useful, unless you like listening to your code. ;)


That's what I call taking code AND music to an upper new level ;)
(ok, seriously, it seems to me that this mode 0 isn't really useful...)

Cydrak wrote:
Starting from the source, it'll blow through the whole 0x0000000..0x7FFFFFF region, usually taking a few minutes each time.

Looped instruments (modes 1 and 2):
1) Play SOUNDxPNT (SCHANNEL_REPEAT_POINT) words from the source.
2) Play SOUNDxLEN (SCHANNEL_LENGTH) words from the repeat point.
3) If looping still enabled (mode == 1), repeat from (2).

Phase (1) occurs even if not looping; in that case it's important to zero the restart point.

Changing modes does work mid-sample; eg. a looping channel that was changed to one-shot, will stop next time it hits the end of the loop. Unfortunately, I couldn't make it accept a new length at this time, it seems to only "take" when restarted. So, you can't abuse that to set a loop that ends before the sample does...


I see, very good. Anyway sample can be stopped resetting the channel enable bit so... right? :)

Cydrak wrote:
(I'll take a look at the RTC shortly: an MP3 alarm was one of my old back-burner projects, and I could swear I'd gotten it working. I used my own API with #defines from the datasheet, however, so it's not obvious what I did differently.)


I would appreciate a lot if you could check if you did something different or in a different order to make it work. Funny it's that if I set the alarm 1 to occour every minute ('minute steady alarm') it works, I get the IRQ :|

Thanks! Ciao! :)

#155027 - Cydrak - Thu Apr 24, 2008 1:54 am

sverx wrote:
sorry, I'm not really good with english so I didn't get what you mean here...

Heh, sorry--some mild frustration there. I feel that GBAtek likes to use plenty of odd, technical words, rather than just explaining what the hardware was meant to do. It makes more sense to me now, but it took time. English is a really good point though: To the extent there's a language gap, I can't complain. While I was born overseas, that doesn't exactly confer German skills on its own. So if these docs weren't English, I'd be in trouble. ;)

sverx wrote:
That's what I call taking code AND music to an upper new level ;)

Hah! Actually, it reminds me far too much of those old, ear-wrecking dot-matrix printers. Though it is occasionally more musical.

sverx wrote:
(ok, seriously, it seems to me that this mode 0 isn't really useful...)

Well, that's the only mode the GBA had. It's just on the NDS, you have the nicer loops.. (Though, a readable SCHANNEL_TIMER, for streaming, would be better still...)

sverx wrote:
Anyway sample can be stopped resetting the channel enable bit so... right? :)

Of course. Have fun!

#155046 - sverx - Thu Apr 24, 2008 12:18 pm

Cydrak wrote:
sverx wrote:
sorry, I'm not really good with english so I didn't get what you mean here...

Heh, sorry--some mild frustration there. I feel that GBAtek likes to use plenty of odd, technical words, rather than just explaining what the hardware was meant to do. It makes more sense to me now, but it took time. English is a really good point though: To the extent there's a language gap, I can't complain. While I was born overseas, that doesn't exactly confer German skills on its own. So if these docs weren't English, I'd be in trouble. ;)


Well... thanks for your explanation but I think I didn't get it completely even this time :|

Cydrak wrote:
sverx wrote:
That's what I call taking code AND music to an upper new level ;)

Hah! Actually, it reminds me far too much of those old, ear-wrecking dot-matrix printers. Though it is occasionally more musical.


So you'll love this :)

Bye!

#155573 - furrykef - Thu May 01, 2008 1:51 am

sverx wrote:
Well... thanks for your explanation but I think I didn't get it completely even this time :|


Cydrak was just sarcastically praising the GBAtek documentation (in other words, insulting it by saying the opposite of what he really means).

- Kef