|
|
|
@ -17,6 +17,9 @@ int mute = false;
@@ -17,6 +17,9 @@ int mute = false;
|
|
|
|
|
unsigned int t = 1; |
|
|
|
|
for(int i = 0; i < len; i++,t++) { |
|
|
|
|
stream[i] = wavegen(t); |
|
|
|
|
if (len - i < 300) { |
|
|
|
|
stream[i] = (float)wavegen(t) * (len - i) / 300.0; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -38,7 +41,7 @@ void start_audio(void) {
@@ -38,7 +41,7 @@ void start_audio(void) {
|
|
|
|
|
} |
|
|
|
|
*/ |
|
|
|
|
//SDL_PauseAudio(0);
|
|
|
|
|
if (Mix_OpenAudio(G_AUDIO_SFREQ,AUDIO_U8,1,G_AUDIO_BSIZE) < 0) { |
|
|
|
|
if (Mix_OpenAudio(G_AUDIO_SFREQ,AUDIO_S8,1,G_AUDIO_BSIZE) < 0) { |
|
|
|
|
fprintf(stderr, "Unable to open audio: %s\n", SDL_GetError()); |
|
|
|
|
exit(1); |
|
|
|
|
} |
|
|
|
@ -58,9 +61,8 @@ play_game_sound(Mix_Chunk *chunk, int len, int channel)
@@ -58,9 +61,8 @@ play_game_sound(Mix_Chunk *chunk, int len, int channel)
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(Mix_PlayChannelTimed(channel, chunk, -1, len) < 0) |
|
|
|
|
if(Mix_PlayChannel(channel, chunk, 1) < 0) |
|
|
|
|
fprintf(stderr, "Unable to play audio: %s\n", SDL_GetError()); |
|
|
|
|
//Mix_FadeInChannelTimed(channel, chunk, -1, 1, len);
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Uint8
|
|
|
|
@ -179,8 +181,15 @@ Uint8 func1(unsigned int t) {
@@ -179,8 +181,15 @@ Uint8 func1(unsigned int t) {
|
|
|
|
|
|
|
|
|
|
Uint8 collision_test(unsigned int t) { |
|
|
|
|
// try not to loop
|
|
|
|
|
return ((t < 3000) * ((t % 5) * (3000 - t % 3000) * 0.00351))
|
|
|
|
|
int x = ((t < 3000) * ((t % 5) * (3000 - t % 3000) * 0.00351))
|
|
|
|
|
+ ((t < 3500) * ((3500 - t % 3500)) * 0.0002 * (t % 14)); |
|
|
|
|
float y = x; |
|
|
|
|
float lerp = 1; |
|
|
|
|
if (t > 80)
|
|
|
|
|
lerp = (100 - t) / 30; |
|
|
|
|
if (lerp > 1) lerp = 1; |
|
|
|
|
if (lerp < 0) lerp = 0; |
|
|
|
|
return y; |
|
|
|
|
return ((t < 3000) * ((t % 5) * (3000 - t % 3000) * 0.00351))
|
|
|
|
|
+ ((4000 - t % 4000) * 0.0003 * (t % 128))
|
|
|
|
|
+ ((t < 3500) * ((3500 - t % 3500)) * 0.0002 * (t % 64)); // has a big low sound
|
|
|
|
@ -201,22 +210,22 @@ void generate_audio(void) {
@@ -201,22 +210,22 @@ void generate_audio(void) {
|
|
|
|
|
unsigned int sfx_len = (G_AUDIO_SFREQ/1000) * G_AUDIO_BSIZE * sfx_len_ms; |
|
|
|
|
sfx_len = G_AUDIO_BSIZE; |
|
|
|
|
|
|
|
|
|
Uint8 *raw_data = malloc(sfx_len);
|
|
|
|
|
Uint8 *raw_data = calloc(sfx_len, sizeof(Uint8));
|
|
|
|
|
fill_audio(winch_sound, raw_data, sfx_len); |
|
|
|
|
game_sounds.rope_pull = Mix_QuickLoad_RAW(raw_data, sfx_len); |
|
|
|
|
Mix_Volume(BC_ROPE_PULL, MIX_MAX_VOLUME * 0.3); |
|
|
|
|
Mix_Volume(BC_ROPE_PULL, MIX_MAX_VOLUME * 0.1); |
|
|
|
|
|
|
|
|
|
Uint8 *raw_data2 = malloc(sfx_len);
|
|
|
|
|
Uint8 *raw_data2 = calloc(sfx_len, sizeof(Uint8));
|
|
|
|
|
fill_audio(collision_test, raw_data2, sfx_len); |
|
|
|
|
game_sounds.collision = Mix_QuickLoad_RAW(raw_data2, sfx_len); |
|
|
|
|
Mix_Volume(BC_COLLISION, MIX_MAX_VOLUME * 1.2); |
|
|
|
|
Mix_Volume(BC_COLLISION, MIX_MAX_VOLUME); |
|
|
|
|
|
|
|
|
|
Uint8 *raw_data3 = malloc(sfx_len);
|
|
|
|
|
Uint8 *raw_data3 = calloc(sfx_len, sizeof(Uint8));
|
|
|
|
|
fill_audio(big_hum, raw_data3, sfx_len); |
|
|
|
|
game_sounds.background = Mix_QuickLoad_RAW(raw_data3, sfx_len); |
|
|
|
|
Mix_Volume(BC_MUSIC, MIX_MAX_VOLUME * 0.1); |
|
|
|
|
|
|
|
|
|
Uint8 *raw_data4 = malloc(sfx_len);
|
|
|
|
|
Uint8 *raw_data4 = calloc(sfx_len, sizeof(Uint8));
|
|
|
|
|
fill_audio(rope_attach, raw_data4, sfx_len); |
|
|
|
|
game_sounds.rope_attach = Mix_QuickLoad_RAW(raw_data4, sfx_len); |
|
|
|
|
Mix_Volume(BC_ROPE_ATTACH, MIX_MAX_VOLUME * 0.1); |
|
|
|
|