Just want to add that I was happy to test the latest NGFX SoundBuilder version, thanks to Blastar for giving me the chance to request some changes.
Most important fix for me is the removal of unwanted "cracking sounds" if too much loud sound effects are played in a short time range.
I have made a small sound player tool for the NGFX SoundBuilder which allows to display and play the samples listed in the exported "sound.h" file.
I would like to share this sound player tool with those who use the NeoBitz C-Dev Kit + DATlib for their projects.
You can watch the tool in action here (set video quality to 240p):
And here is the code:
sound_test.h
#ifndef __SOUND_TEST_H__
#define __SOUND_TEST_H__
void sound_test_ngfx();
#endif
sound_test.c
#include <stdio.h>
#include <stdlib.h>
#include <input.h>
#include <DATlib.h>
#include "sound_test.h"
#include "sound.h"
BYTE p1,p2,ps,p1e,p2e;
void sound_test_ngfx()
{
short timer_state=0;
int vbl_count=0;
int play_time_frames=0;
int play_time_sec=0;
int play_time_min=0;
int dec_number=32; // start value 32 (Hex 0x20), adresses below used for sound driver commands
int sample_number=0;
short volume=100;
short input_delay=10;
char const* display_hex[112] =
{
"0x00", "0x01", "0x02", "0x03", "0x04", "0x05", "0x06", "0x07", "0x08", "0x09", "0x0A", "0x0B", "0x0C", "0x0D", "0x0E", "0x0F", // 0-15
"0x10", "0x11", "0x12", "0x13", "0x14", "0x15", "0x16", "0x17", "0x18", "0x19", "0x1A", "0x1B", "0x1C", "0x1D", "0x1E", "0x1F", // 16-31
"0x20", "0x21", "0x22", "0x23", "0x24", "0x25", "0x26", "0x27", "0x28", "0x29", "0x2A", "0x2B", "0x2C", "0x2D", "0x2E", "0x2F", // 32-47
"0x30", "0x31", "0x32", "0x33", "0x34", "0x35", "0x36", "0x37", "0x38", "0x39", "0x3A", "0x3B", "0x3C", "0x3D", "0x3E", "0x3F", // 48-63
"0x40", "0x41", "0x42", "0x43", "0x44", "0x45", "0x46", "0x47", "0x48", "0x49", "0x4A", "0x4B", "0x4C", "0x4D", "0x4E", "0x4F", // 64-79
"0x50", "0x51", "0x52", "0x53", "0x54", "0x55", "0x56", "0x57", "0x58", "0x59", "0x5A", "0x5B", "0x5C", "0x5D", "0x5E", "0x5F", // 80-95
"0x60", "0x61", "0x62", "0x63", "0x64", "0x65", "0x66", "0x67", "0x68", "0x69", "0x6A", "0x6B", "0x6C", "0x6D", "0x6E", "0x6F", // 99-111
};
volMEMWORD(0x401ffe)=0x6122; // background color
volMEMWORD(0x400002)=0x7CB6; // fix layer font color
volMEMWORD(0x400004)=0x6122; // fix layer background color
volMEMWORD(0x400006)=0x6122; // fix layer background color
volMEMWORD(0x40000A)=0x6122; // fix layer background color
LSPCmode=0x900;
initGfx();
clearFixLayer();
clearSprites(1, 381);
SCClose();
fixPrintf( 2, 2, 0, 0,"------------------------------------");
fixPrintf( 2, 3, 0, 1,"SAMPLE PLAYER for NGFX Sound Builder");
fixPrintf( 2, 4, 0, 2,"SAMPLE PLAYER for NGFX Sound Builder");
fixPrintf( 2, 5, 0, 0,"------------------------------------");
fixPrintf( 2, 7, 0, 1, "Samples Total: %03d", SAMPLE_COUNT); // total amount of samples imported from sound.h
fixPrintf( 2, 8, 0, 2, "Samples Total: %03d", SAMPLE_COUNT); // total amount of samples imported from sound.h
fixPrintf( 2, 10, 0, 1,"Sample Address:");
fixPrintf( 2, 11, 0, 2,"Sample Address:");
fixPrintf(18, 10, 0, 0,"NUM. HEX. DEC.");
fixPrintf(22, 10, 0, 1,"l");
fixPrintf(28, 10, 0, 1,"l");
fixPrintf(22, 11, 0, 1,"l");
fixPrintf(28, 11, 0, 1,"l");
fixPrintf( 2, 13, 0, 1,"Sample Name:");
fixPrintf( 2, 14, 0, 2,"Sample Name:");
fixPrintf( 2, 16, 0, 1,"Playback Time:");
fixPrintf( 2, 17, 0, 2,"Playback Time:");
fixPrintf(17, 16, 0, 0,"TIMER");
fixPrintf(25, 16, 0, 0,"FRAMES");
fixPrintf(23, 16, 0, 1,"l");
fixPrintf(23, 17, 0, 1,"l");
fixPrintf( 2, 19, 0, 1,"Volume:");
fixPrintf( 2, 20, 0, 2,"Volume:");
fixPrintf( 2, 22, 0, 0,"------------------------------------");
fixPrintf( 2, 23, 0, 0,"P1 A: PLAY SAMPLE");
fixPrintf( 2, 24, 0, 0,"P1 B: ADPCM STOP");
fixPrintf( 2, 25, 0, 0,"P1 \x12\x13: SELECT +/-");
fixPrintf( 2, 26, 0, 0,"P1 \x11\x10: VOLUME +/-");
fixPrintf(21, 23, 0, 0,"P2 A: FADE OUT");
fixPrintf(21, 24, 0, 0,"P2 B: FADE IN");
fixPrintf(21, 25, 0, 0,"P2 C: MUTE VOLUME");
fixPrintf(21, 26, 0, 0,"P2 D: MAX. VOLUME");
fixPrintf( 2, 27, 0, 0,"------------------------------------");
fixPrintf( 2, 28, 0, 0,"P1 D: EXIT Ver.0.5 NeoHomeBrew.com");
do{
waitVBlank();
ps=volMEMBYTE(PS_CURRENT);
p1=volMEMBYTE(P1_CURRENT);
p2=volMEMBYTE(P2_CURRENT);
if((p1&JOY_UP)&&input_delay==0)
{
input_delay=10;
if((dec_number-32)>0) dec_number-=1;
}
if((p1&JOY_DOWN)&&input_delay==0)
{
input_delay=10;
if((dec_number-32)<(SAMPLE_COUNT-1)) dec_number+=1;
}
if((p1&JOY_LEFT)&&input_delay==0)
{
input_delay=10;
if(volume>0)
{
send_sound_command(ADPCM_DEC_VOL);
volume-=1;
}
}
if((p1&JOY_RIGHT)&&input_delay==0)
{
input_delay=10;
if(volume<100)
{
send_sound_command(ADPCM_INC_VOL);
volume+=1;
}
}
if((p1&JOY_A)&&input_delay==0)
{
input_delay=10;
send_sound_command(dec_number);
// activate and reset playback timer
timer_state=1;
play_time_frames=0;
play_time_sec=0;
play_time_min=0;
vbl_count=0;
}
if((p1&JOY_B)&&input_delay==0)
{
input_delay=10;
send_sound_command(ADPCM_STOP);
timer_state=0; // stop playback timer
}
if((p1&JOY_C)&&input_delay==0)
{
input_delay=10;
send_sound_command(ADPCMB_LOOP_STOP);
timer_state=0; // stop playback timer
}
if(p1&JOY_D)
{
// exit game mode (if used in user subroutine)
volMEMBYTE(0x10FDB6)=0x00; // sets BIOS-PLAYER-MOD1 to 0 (P1 Never Played)
volMEMBYTE(0x10FDB7)=0x00; // sets BIOS-PLAYER-MOD2 to 0 (P2 Never Played)
clearFixLayer();
break;
}
if((p2&JOY_A)&&input_delay==0)
{
input_delay=10;
send_sound_command(ADPCM_FADE_OUT);
volume=0;
}
if((p2&JOY_B)&&input_delay==0)
{
input_delay=10;
send_sound_command(ADPCM_FADE_IN);
volume=100;
}
if((p2&JOY_C)&&input_delay==0)
{
input_delay=10;
send_sound_command(ADPCM_MUTE);
volume=0;
}
if((p2&JOY_D)&&input_delay==0)
{
input_delay=10;
send_sound_command(ADPCM_SET_MAX_VOL);
volume=100;
}
sample_number = dec_number-32; // calculate sample number
if(input_delay>0) input_delay-=1; // input_delay countdown
if(timer_state==1) // update timer if activated
{
play_time_frames +=1;
vbl_count +=1;
if(play_time_frames==60) // 60 frames per second
{
play_time_sec+=1;
play_time_frames=0;
if(play_time_sec==60)
{
play_time_min+=1;
play_time_sec=0;
}
}
}
// display sound sample data ////////////////////////////////////////////////////////////////////////////
fixPrintf(18, 11, 0, 0, "%03d", sample_number); // sample number imported from sound.h
fixPrintf(24, 11, 0, 0, "%s", display_hex[dec_number]); // display hex adress
fixPrintf(30, 11, 0, 0, "%03d", dec_number); // decimal number of hex adress
fixPrintf(15, 13, 0, 1, "%s", SoundList[sample_number]); // sample name string imported from sound.h
fixPrintf(15, 14, 0, 2, "%s", SoundList[sample_number]); // sample name string imported from sound.h
fixPrintf(17, 17, 0, 0,"%02d:%02d", play_time_min, play_time_sec);
fixPrintf(25, 17, 0, 0,"%06d", vbl_count);
fixPrintf(10, 19, 0, 1,"%03d", volume);
fixPrintf(10, 20, 0, 2,"%03d", volume);
}while(!(p1&JOY_D));
}