Try this sound sample (I haven't retested it since 2006, but should work).
(you need chimes.wav 121252 bytes, PCM, 48Khz, 16 bits)
Makefile (you need true tabulations at beginning of indented lines) :
CODE
#
# update this variable to wherever you installed the OpenXDK libraries
#
PREFIX = /usr/local/openxdk
CC = gcc
CPP = cpp
CXBE = $(PREFIX)/bin/cxbe
SDLFLAGS = -DENABLE_XBOX -DDISABLE_CDROM
CC_FLAGS = -c -g -std=gnu99 -ffreestanding -nostdlib -fno-builtin -fno-exceptions -mno-cygwin -march=i386 $(SDLFLAGS)
INCLUDE = -I$(PREFIX)/i386-pc-xbox/include -I$(PREFIX)/include -I$(PREFIX)/include/SDL
CLINK = -nostdlib
ALIGN = -Wl,--file-alignment,0x20 -Wl,--section-alignment,0x20
SHARED = -shared
ENTRYPOINT = -Wl,--entry,_WinMainCRTStartup
STRIP = -Wl,--strip-all
LD_FLAGS = $(CLINK) $(ALIGN) $(SHARED) $(ENTRYPOINT) $(STRIP)
LD_DIRS = -L$(PREFIX)/i386-pc-xbox/lib -L$(PREFIX)/lib
#LD_LIBS = $(LD_DIRS) -lSDL -lopenxdk -lhal -lusb -lc -lxboxkrnl
LD_LIBS = $(LD_DIRS) -lSDL -lm -lopenxdk -lhal -lc -lusb -lc -lxboxkrnl -lc -lhal -lxboxkrnl -lhal -lopenxdk -lc
all: default.exe
.c.o:
$(CC) -c $< $(CC_FLAGS) $(INCLUDE)
default.exe: test.o
$(CC) -o $@ $< $(LD_LIBS) $(LD_FLAGS)
$(CXBE) -TITLE:"$@" -DUMPINFO:"default.cxbe" -OUT:"default.xbe" $@ > /dev/null
clean:
rm -f *.o *.exe *.dll *.xbe *.cxbe
testAudio2.c :
CODE
#include <hal/xbox.h>
#include <hal/fileio.h>
#include <openxdk/debug.h>
#include <xboxkrnl/xboxkrnl.h>
#include "string.h"
#include "stdio.h"
#include <stdlib.h>
#include <hal/input.h>
#include <hal/audio.h>
//"D:" stands for ".", it seems.
void readFromFile(char *buffer, int size)
{
int handle;
//"d:/" is considered as "./"
XCreateFile(&handle, "d:/chimes.wav", GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL);
int newLocation, read;
XSetFilePointer(handle, 0x3A*0+64, &newLocation, FILE_BEGIN);
XReadFile(handle, buffer, size, &read);
XCloseHandle(handle);
}
#define BUF_SIZE 4096
char *current=NULL;
int left=0;
void mycallback(void *pac97device, void *data)
{
if (left==0) return;
if (current==NULL) return;
if (left>BUF_SIZE)
{
XAudioProvideSamples(current, BUF_SIZE, false);
current += BUF_SIZE;
left -= BUF_SIZE;
}
else
{
XAudioProvideSamples(current, left, true);
current = NULL;
left=0;
}
}
void initplayback()
{
int bufferSize;
char *buffer;
bufferSize = 121188; //chimes.wav=64 bytes of header and 121188 bytes of data
buffer = (char *)malloc(bufferSize);
current=buffer;
left=bufferSize;
debugPrint("Reading data\n");
readFromFile(buffer, bufferSize);
debugPrint("Init\n");
XAudioInit(16, 2, mycallback, NULL);
// lets give it something to play...
XAudioProvideSamples(current, BUF_SIZE, false); current += BUF_SIZE; left -= BUF_SIZE;
debugPrint("Playing\n");
// and now play...
XAudioPlay();
}
void XBoxStartup()
{
XKEYBOARD_STROKE xk;
int i;
int initplaybackdone=0;
XInput_Init();
debugPrint("Hit B to exit program. Hit repeatedly A. Y starts playback.\n");
while (!done)
{
//Let's check for joypad events
//(assuming tester is hitting A button all the time)
XInput_GetEvents();
for(i=0; i<4; i++)
{
if(g_Pads[i].PressedButtons.ucAnalogButtons[XPAD_A])
debugPrint("Pressed A on Pad %d - %d\n", i+1, g_Pads[i].CurrentButtons.ucAnalogButtons[XPAD_A]);
if(g_Pads[i].PressedButtons.ucAnalogButtons[XPAD_B])
{
debugPrint("Pressed B on Pad %d - %d\n", i+1, g_Pads[i].CurrentButtons.ucAnalogButtons[XPAD_B]);
done=1;
}
if(g_Pads[i].PressedButtons.ucAnalogButtons[XPAD_X])
debugPrint("Pressed X on Pad %d - %d\n", i+1, g_Pads[i].CurrentButtons.ucAnalogButtons[XPAD_X]);
if(g_Pads[i].PressedButtons.ucAnalogButtons[XPAD_Y])
{
debugPrint("Pressed Y on Pad %d - %d\n", i+1, g_Pads[i].CurrentButtons.ucAnalogButtons[XPAD_Y]);
if (!initplaybackdone)
{
initplayback();
initplaybackdone=1;
}
}
}
XSleep(40);
}
debugPrint("End of test. Rebooting...\n");
XSleep(1000);
XReboot();
}