GP32 Basic Sound Questions (using Mr.mirko)


0-bake

Active Member
Joined
Dec 15, 2003
Messages
538
hi,

i have a few question in adding sound (effects) to a game.
as i never did something with sound before, i'm a bit confused.

in some threads there's some diskussion about sound in general, but i couldn't find anything that helps me.
in which format do the sound files have to be, so that i can include them into my project?
and actually how can i play them?

is there a procedure like play(sound1); ?
and what, if a new sound is started and the last one hasn't finished? is that what a "mixer" does? seems so...

so, i would like to know, what i have to do, to get my recorded sound sample into my project.
there are so many examples for sprites and graphics, but almost nothing to make the Gp32 go peeep ;)

i read that the sound routines in mr.mirko's aren't finished, but i just need 3 differen't kind of sound effects ind low quality, so i guess it may be ok with that...
 
I don't know anything about Mr Mirko's sdk but I imagine your first step will be to convert your samples to raw pcm data and then convert that to c source with a bin2c type proggy.
 
I would recommend to use spiv's mlib. music and sound effect hanndling made easy. for converting samples I suggest using 'sox'.
 
ahh cool, thx for the replies.
ok, i'm messing around with it, will have a look at spiv's mlib.

strange, i thought audacity could export as "raw data", but it can't. must have mixed up something....
 
hm, im somehow stuck :(
i found an example in Mr.Mirko's SDK that does exactly what i want to do.
but i can't compile it.

the example contains everything, even the makefile. the makefile ist:

Code:
# This Makefile is very easy to use !
# Only edit PRG and OBJS 
# Dont touch anything else

CC = arm-elf-gcc
LD = arm-elf-gcc
AS = arm-elf-as
AR = arm-elf-ar

PRG  = modplay
OBJS = modfile1.o  modfile2.o  modplay.o  sample1.o  sample2.o  sample3.o

LIBS      = -L../lib -lmirkoSDK -lm
CRT0      = ../lib/crt0.S
LNKSCRIPT = ../lib/lnkscript
INCLUDES  = -I../include
CFLAGS    = $(INCLUDES) -O2 -s -mtune=arm9tdmi

all:	$(OBJS)
	$(CC) -c -o crt0.o $(CRT0)
	$(LD) -nostartfiles -s -Wall -Wl,-Map,Test.map  -T $(LNKSCRIPT) crt0.o -o $(PRG).elf $(OBJS) $(LIBS)
	arm-elf-objcopy -O binary $(PRG).elf $(PRG).bin
	b2fxec -a Mirko_Roller -t SDK_EXAMPLE_$(PRG) $(PRG).bin $(PRG).fxe

install:
	gplink put $(PRG).fxe gpmm

clean:
	rm -f *.o *~ Test.map *.bin *.elf

but if i type "make" in the dir, i get errors:
arm-elf-gcc -I../include -O2 -s -mtune=arm9tdmi -c -o modfile1.o modfile1.c
make: arm-elf-gcc: Command not found
make: *** [modfile1.o] Error 127

i tried to adapt the code from the main modfile.c to one of my project templates (containing may "all in wonder" makefile), but i can't include the sample-files to my project.
my makefile has no line similar to: OBJS = modfile1.o modfile2.o modplay.o sample1.o sample2.o sample3.o

so i added this line (and the sample-files to the new directory), but nothing happened.

my makefile is:
Code:
#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM)
endif

include $(DEVKITARM)/gp32_rules

#---------------------------------------------------------------------------------
# options for FXE
#---------------------------------------------------------------------------------
AUTHOR	:=	O-bake
TITLE	:=	template

#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
TARGET  :=	template
BUILD  :=	build
SOURCES  :=	source sprites
INCLUDES	:=	include

#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH	:=	

CFLAGS	:=	-Wall -O2 -mtune=arm9tdmi\
    -fomit-frame-pointer\
  	-ffast-math \
  	$(ARCH)

CFLAGS	+=	$(INCLUDE)

AFLAGS	:=	$(ARCH)
LDFLAGS	=	$(ARCH) -Wl,-Map,$(notdir $@).map

#---------------------------------------------------------------------------------
# path to tools - this can be deleted if you set the path in windows
#---------------------------------------------------------------------------------
export PATH  :=	$(DEVKITARM)/bin:$(PATH)

#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS  :=	-lmirkoSDK_GEEPEE


#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS	:=	$(LIBMIRKO)


#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------

export OUTPUT	:=	$(CURDIR)/$(TARGET)

export VPATH	:=	$(foreach dir,$(SOURCES),$(CURDIR)/$(dir))
export DEPSDIR	:=	$(CURDIR)/$(BUILD)


CFILES  :=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES	:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES  :=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BMPFILES	:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.bmp)))
BINFILES	:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.bin)))

#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
	export LD	:=	$(CC)
else
	export LD	:=	$(CXX)
endif

export OFILES	:=	$(BINFILES:.bin=.o) $(BMPFILES:.bmp=.o)\
    	$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)

export INCLUDE	:=	$(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
    	$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
    	-I$(CURDIR)/$(BUILD)

export LIBPATHS	:=	$(foreach dir,$(LIBDIRS),-L$(dir)/lib)

.PHONY: $(BUILD) clean

#---------------------------------------------------------------------------------
$(BUILD):
	@[ -d $@ ] || mkdir -p $@
	@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile

#---------------------------------------------------------------------------------
clean:
	@echo clean ...
	@rm -fr $(BUILD) *.elf


#---------------------------------------------------------------------------------
else

DEPENDS	:=	$(OFILES:.o=.d)

#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).fxe	:	$(OUTPUT).bin

$(OUTPUT).bin	:	$(OUTPUT).elf

$(OUTPUT).elf	:	$(OFILES)


#---------------------------------------------------------------------------------
%.o	:	%.bin
#---------------------------------------------------------------------------------
	@echo $(notdir $<)
	@$(bin2o)

#---------------------------------------------------------------------------------
%.bin	:	%.bmp
#---------------------------------------------------------------------------------
	@echo $(notdir $<)
	bmp2bin -r -x $< $@

-include $(DEPENDS)

#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

as you can see, the both makefiles have not much in common, but i don't understand why the one in mirko's example won't work.
 
Well, the first makefile assumes certain names for your compiler/linker.

It seems your compiler (most likely gcc) isn't named "arm-elf-gcc" or it can't be found.

Because it can't find the compiler, it aborts.
 
yea, i got it working now and implemented it in my game, but it's very crackling noisy right now.
it even makes noises if no sample plays. i have to test a few things...
 
As long as you use only 2 of the 3 DMA channels, you're allright. So check if your gfx lib is using DMA for its blitting.
 
how can i see, if i'm using DMA?
as far as i know, i didn't do anything. except some functions of the mr.mirko set using DMA...
 
0-bake posted on Dec 25 2005 at 03:39 AM said:
how can i see, if i'm using DMA?
as far as i know, i didn't do anything. except some functions of the mr.mirko set using DMA...
​

if the sound crackles, check your drawing to the screen, if your only drawing to the framebuffer, and not to some "nearby" memory.
Are you using FRAMEBUFFER1/2 memory ? DO not use some malloc memory for framebuffer.

Also do not use empty loops, like
while (1) wait_for_keypress;

Do remove all optimizations from the Makefile. Only use "-O0" for all Files.

If your project depends on many different *.c files, compile only math/mem heavy object files with "-O0".

GOOD LUCK !!
 
Last edited by a moderator:
i just came home from my christmas vacations and i want to continue working on my project this evening.

i guess, i'm doing everything correct, but i have no idea, what "compiling with -O0" means.
i posted my "all in wonder" makefile obove and i have really no clue what it does.
the string "-O0" is not in that makefile, so i guess, i'm not compiling with that command.
but i don't know, what i have to replace/add to do so.

thanks anyways.
 
0-bake posted on Dec 27 2005 at 03:44 PM said:
i just came home from my christmas vacations and i want to continue working on my project this evening.

i guess, i'm doing everything correct, but i have no idea, what "compiling with -O0" means.
i posted my "all in wonder" makefile obove and i have really no clue what it does.
the string "-O0" is not in that makefile, so i guess, i'm not compiling with that command.
but i don't know, what i have to replace/add to do so.

thanks anyways.
​

Thats really why i like "all-in-wonder" makefiles, youre LOST... ( btw very good TV show... )

chage:
CFLAGS := -Wall -O2 -mtune=arm9tdmi\
-fomit-frame-pointer\
-ffast-math \
$(ARCH)

TO:
CFLAGS := -Wall -O0 -mtune=arm9tdmi

REMOVE: -fomit-frame-pointer -ffast-math $(ARCH)
 
Last edited by a moderator:
Back
Top