Sound garbage with small demo

Topics related to the API, programming discussions & questions, coding tips, bugs, etc. should go here.
User avatar
Janka
Posts: 214
Joined: Fri Sep 21, 2012 10:46 pm
Location: inside Out

Sound garbage with small demo

Post by Janka »

Because my work-in-progress produces sound garbage by itself, I think I'm missing some initialisation. I reduced it to a simple example, taking tune and patches from the Dr Mario example game. I use the latest kernel from svn trunk, which works fine with the games I compiled myself.

Code: Select all

#include <avr/io.h>
#include <stdlib.h>
#include <avr/pgmspace.h>
#include <uzebox.h>
#include <math.h>
#include <stdio.h>

#include "data/patches.inc"
#include "data/drmario_music.inc"

int main(void) {
	InitMusicPlayer(patches);
	StartSong(song_drmario_main);
	for (;;) {
		WaitVsync(1);
	}
	return 0;
}
What I am missing?
User avatar
uze6666
Site Admin
Posts: 4801
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: Sound garbage with small demo

Post by uze6666 »

That should be it, there's no other initialization...what is the issue exactly? Can you post a HEX or the sources?
User avatar
Janka
Posts: 214
Joined: Fri Sep 21, 2012 10:46 pm
Location: inside Out

Re: Sound garbage with small demo

Post by Janka »

Well, these *are* the actual sources. Hex file attached. It should play the tune from the Dr. Mario game, but all it produces is a fast "rap, rap, rap, rap", like a small sound sample is always repeated. It depends on VRAM contents, too, when I clear VRAM, rapping turns into yelling.
Attachments
Tests.hex
(37.9 KiB) Downloaded 238 times
User avatar
uze6666
Site Admin
Posts: 4801
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: Sound garbage with small demo

Post by uze6666 »

Hi Janka,

All I hear from the hex is a buzz? Sounds like some kernel reserved RAM overwriting issue, the sound buffer repeats some trash. Hard to tell what's the problem, do you address ram directly? Array bound issue? You can PM me the sources if you want, I'll give it a look.
User avatar
Janka
Posts: 214
Joined: Fri Sep 21, 2012 10:46 pm
Location: inside Out

Re: Sound garbage with small demo

Post by Janka »

Sorry. In the last post, I mixed in the patches set from uzepede. When I use the patches set from Dr. Mario, I get no sound at all. Please see another hex file.
Attachments
Tests.hex
(44.55 KiB) Downloaded 234 times
Last edited by Janka on Mon Sep 24, 2012 12:14 am, edited 1 time in total.
User avatar
Janka
Posts: 214
Joined: Fri Sep 21, 2012 10:46 pm
Location: inside Out

Re: Sound garbage with small demo

Post by Janka »

uze6666 wrote:You can PM me the sources if you want, I'll give it a look.
It's the sources from above. Really!
Attachments
Tests.tar.gz
(5.75 KiB) Downloaded 235 times
User avatar
Janka
Posts: 214
Joined: Fri Sep 21, 2012 10:46 pm
Location: inside Out

Re: Sound garbage with small demo

Post by Janka »

Ok, now I got a little nearer to my problem. The difference between silence and sound garbage is in the Makefile. If I put

Code: Select all

KERNEL_OPTIONS  = -DVIDEO_MODE=3 -DINTRO_LOGO=0
KERNEL_OPTIONS += -DSOUND_CHANNEL_4_ENABLE=0 -DSOUND_CHANNEL_2_ENABLE=1 -DSOUND_CHANNEL_3_ENABLE=1 -DMIXER_CHAN4_TYPE=1
KERNEL_OPTIONS += -DMAX_SPRITES=20
KERNEL_OPTIONS += -DRAM_TILES_COUNT=32
garbage and segfault is what I get. I think there are some ressources missing to allow all these features at the same time?
User avatar
uze6666
Site Admin
Posts: 4801
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: Sound garbage with small demo

Post by uze6666 »

Hmm, something is wrong...the emulator (v1.15) hangs on that last hex. Are you sure you are using the latest kernel files from the trunk? I have taken your file and just did make and everything works as expected. What's your environment: linux, windows, mac? I've attached your project with the latest kernel. The hex in the /default folder works, try running make again to see what happens.
Attachments
Tests_uze.zip
(317.73 KiB) Downloaded 233 times
Tests.hex
(44.83 KiB) Downloaded 241 times
User avatar
uze6666
Site Admin
Posts: 4801
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: Sound garbage with small demo

Post by uze6666 »

Do you need PCM samples in your game? If so indeed you need -DMIXER_CHAN4_TYPE=1 and you don't need -DSOUND_CHANNEL_4_ENABLE=0, since that turns off the PCM channel. You can use -DSOUND_MIXER=1 to use the inline mixer and recover some ram. Also what's the RAM/Flash utilization when you compile?
AVR Memory Usage
----------------
Device: atmega644

Program: 16316 bytes (24.9% Full)
(.text + .data + .bootloader)

Data: 2928 bytes (71.5% Full)
(.data + .bss + .noinit)
User avatar
Janka
Posts: 214
Joined: Fri Sep 21, 2012 10:46 pm
Location: inside Out

Re: Sound garbage with small demo

Post by Janka »

I'll try and report tomorrow. Thanks for your time.
Post Reply