Skip to content
This repository has been archived by the owner on Jan 22, 2022. It is now read-only.

Commit

Permalink
Pop sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
Nazar Taran committed Feb 3, 2021
1 parent fd3baa9 commit 6ad2d97
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
3 changes: 3 additions & 0 deletions client/inc/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 84,9 @@

#define MEDIA_DIR "media_client/"
#define TEMP_DIR "temp/"
#define SOUND_POKEMON 0x01
#define SOUND_LOW_POP 0x02
#define SOUND_HIGH_POP 0x03

typedef unsigned long long csum_t;

Expand Down
2 changes: 1 addition & 1 deletion client/src/screen_home.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 72,7 @@ static void build_fact(GtkWidget *main)
gtk_widget_set_halign(t_pokefact.pokemon_text, GTK_ALIGN_START);
gtk_box_pack_start(GTK_BOX(fact_box), t_pokefact.pokemon_text, FALSE, FALSE, 0);

g_signal_connect(G_OBJECT(fact_block), "button_press_event", G_CALLBACK(event_play_audio), (gpointer)(intptr_t)0);
g_signal_connect(G_OBJECT(fact_block), "button_press_event", G_CALLBACK(event_play_audio), (gpointer)(intptr_t)SOUND_POKEMON);
}

static void build_welcome(GtkWidget *main)
Expand Down
5 changes: 4 additions & 1 deletion client/src/send_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 6,7 @@ void *send_message() {
if (!strcmp(text, "pikachu") || !strcmp(text, "Pikachu")) {
mx_strdel(&t_pokefact.pokemon_fact_audio);
t_pokefact.pokemon_fact_audio = strdup("client/data/pokemon-audio/9.wav");
play_audio(0);
play_audio(SOUND_POKEMON);
}

int chat_id = msg_data.chat_id;
Expand Down Expand Up @@ -40,6 40,7 @@ void *send_message() {
mx_strdel(&text);
cJSON_Delete(json);
cJSON_Delete(response);
play_audio(SOUND_HIGH_POP);
return NULL;
}

Expand Down Expand Up @@ -72,6 73,7 @@ void *send_sticker() {
mx_strdel(&json_string);
cJSON_Delete(json);
cJSON_Delete(response);
play_audio(SOUND_HIGH_POP);
return NULL;
}

Expand Down Expand Up @@ -177,5 179,6 @@ void *send_photo() {
mx_strdel(&json_string);
cJSON_Delete(json_photo);
cJSON_Delete(response);
play_audio(SOUND_HIGH_POP);
return NULL;
}
16 changes: 7 additions & 9 deletions client/src/sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 11,20 @@ void event_play_audio(GtkWidget *widget, GdkEventButton *event, gpointer type)
}

void play_audio(int type) {
Mix_Chunk *sound = NULL;
switch(type)
{
case 0: {
Mix_Chunk *sound = Mix_LoadWAV(t_pokefact.pokemon_fact_audio);
case SOUND_POKEMON:
sound = Mix_LoadWAV(t_pokefact.pokemon_fact_audio);
Mix_PlayChannel(-1, sound, 0);
break;
}
case 1: {
Mix_Chunk *sound = Mix_LoadWAV("client/data/sounds/low_pop.wav");
case SOUND_LOW_POP:
sound = Mix_LoadWAV("client/data/sounds/low_pop.wav");
Mix_PlayChannel(-1, sound, 0);
break;
}
case 2: {
Mix_Chunk *sound = Mix_LoadWAV("client/data/sounds/high_pop.wav");
case SOUND_HIGH_POP:
sound = Mix_LoadWAV("client/data/sounds/high_pop.wav");
Mix_PlayChannel(-1, sound, 0);
break;
}
}
}
2 changes: 2 additions & 0 deletions client/src/updater.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 34,8 @@ static void generate_new_message(int user_id, int avatar, char *username, char *
new_incoming_sticker(t_msg.chat_screen, sticker);
else if (photo_path)
new_incoming_embedded(t_msg.chat_screen, photo_path);
if (!upd_data.filling_init)
play_audio(SOUND_LOW_POP);
}
}

Expand Down

0 comments on commit 6ad2d97

Please sign in to comment.