Skip to content

Commit

Permalink
Ultimi fix all'opzione "Start/Stop WAV recording".
Browse files Browse the repository at this point in the history
  • Loading branch information
punesemu committed Apr 6, 2017
1 parent 2c374df commit d553a51
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 19 deletions.
11 changes: 11 additions & 0 deletions src/audio/wave.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "wave.h"
#include "snd.h"
#include "info.h"
#include "text.h"

struct _wav {
FILE *outfile;
Expand Down Expand Up @@ -104,6 +105,8 @@ BYTE wave_open(uTCHAR *filename, int samples) {

info.wave_in_record = TRUE;

text_add_line_info(1, "start wav recording");

snd_playback_unlock(SNDCACHE);

return (EXIT_OK);
Expand All @@ -114,6 +117,12 @@ void wave_close(void) {
if (wav.outfile) {
long int actual_size;

// scrivo l'ultimo segmento
if (wav.count) {
wav.subchunk2size += fwrite(wav.buffer, 1, wav.count * snd.channels * (16 / 8),
wav.outfile);
}

actual_size = ftell(wav.outfile) - 8;

// ChunkSize
Expand All @@ -131,6 +140,8 @@ void wave_close(void) {

fclose(wav.outfile);
wav.outfile = NULL;

text_add_line_info(1, "stop wav recording");
}

if (wav.buffer) {
Expand Down
6 changes: 3 additions & 3 deletions src/gui/designer/application.ui
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
<addaction name="menu_Disk_Side"/>
<addaction name="action_Eject_Insert_Disk"/>
<addaction name="separator"/>
<addaction name="action_Start_Stop_record_WAV"/>
<addaction name="action_Start_Stop_WAV_recording"/>
<addaction name="separator"/>
<addaction name="action_Fullscreen"/>
<addaction name="action_Save_Screenshot"/>
Expand Down Expand Up @@ -2196,13 +2196,13 @@
<string>Fullscreen in &amp;window</string>
</property>
</action>
<action name="action_Start_Stop_record_WAV">
<action name="action_Start_Stop_WAV_recording">
<property name="icon">
<iconset resource="application.qrc">
<normaloff>:/icon/icons/wav_start.png</normaloff>:/icon/icons/wav_start.png</iconset>
</property>
<property name="text">
<string>Start/Stop record &amp;WAV</string>
<string>Start/Stop &amp;WAV recording</string>
</property>
</action>
</widget>
Expand Down
2 changes: 1 addition & 1 deletion src/gui/dlgInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ void dlgInput::update_dialog() {
update_text_shortcut(parentMain->ui->action_Insert_Coin, SET_INP_SC_INSERT_COIN);
update_text_shortcut(parentMain->ui->action_Switch_sides, SET_INP_SC_SWITCH_SIDES);
update_text_shortcut(parentMain->ui->action_Eject_Insert_Disk, SET_INP_SC_EJECT_DISK);
update_text_shortcut(parentMain->ui->action_Start_Stop_record_WAV, SET_INP_SC_WAV);
update_text_shortcut(parentMain->ui->action_Start_Stop_WAV_recording, SET_INP_SC_WAV);
update_text_shortcut(parentMain->ui->action_Fullscreen, SET_INP_SC_FULLSCREEN);
update_text_shortcut(parentMain->ui->action_Pause, SET_INP_SC_PAUSE);
update_text_shortcut(parentMain->ui->action_Fast_Forward, SET_INP_SC_FAST_FORWARD);
Expand Down
28 changes: 14 additions & 14 deletions src/gui/mainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,11 +557,9 @@ void mainWindow::update_menu_nes() {
if (info.no_rom | info.turn_off) {
ui->action_Hard_Reset->setEnabled(false);
ui->action_Soft_Reset->setEnabled(false);
ui->action_Start_Stop_record_WAV->setEnabled(false);
} else {
ui->action_Hard_Reset->setEnabled(true);
ui->action_Soft_Reset->setEnabled(true);
ui->action_Start_Stop_record_WAV->setEnabled(true);
}

if (vs_system.enabled == TRUE) {
Expand Down Expand Up @@ -598,17 +596,17 @@ void mainWindow::update_menu_nes() {
sc = (QString *)settings_inp_rd_sc(SET_INP_SC_WAV, KEYBOARD);

if (info.no_rom | info.turn_off) {
ui->action_Start_Stop_record_WAV->setEnabled(false);
ui->action_Start_Stop_record_WAV->setText(tr("Start/STop record &WAV") + '\t' + ((QString)*sc));
ui->action_Start_Stop_record_WAV->setIcon(QIcon(":/icon/icons/wav_start.png"));
ui->action_Start_Stop_WAV_recording->setEnabled(false);
ui->action_Start_Stop_WAV_recording->setText(tr("Start/Stop &WAV recording") + '\t' + ((QString)*sc));
ui->action_Start_Stop_WAV_recording->setIcon(QIcon(":/icon/icons/wav_start.png"));
} else {
ui->action_Start_Stop_record_WAV->setEnabled(true);
ui->action_Start_Stop_WAV_recording->setEnabled(true);
if (info.wave_in_record) {
ui->action_Start_Stop_record_WAV->setText(tr("Stop record &WAV") + '\t' + ((QString)*sc));
ui->action_Start_Stop_record_WAV->setIcon(QIcon(":/icon/icons/wav_stop.png"));
ui->action_Start_Stop_WAV_recording->setText(tr("Stop &WAV recording") + '\t' + ((QString)*sc));
ui->action_Start_Stop_WAV_recording->setIcon(QIcon(":/icon/icons/wav_stop.png"));
} else {
ui->action_Start_Stop_record_WAV->setText(tr("Start record &WAV") + '\t' + ((QString)*sc));
ui->action_Start_Stop_record_WAV->setIcon(QIcon(":/icon/icons/wav_start.png"));
ui->action_Start_Stop_WAV_recording->setText(tr("Start &WAV recording") + '\t' + ((QString)*sc));
ui->action_Start_Stop_WAV_recording->setIcon(QIcon(":/icon/icons/wav_start.png"));
}
}

Expand Down Expand Up @@ -1308,7 +1306,7 @@ void mainWindow::shortcuts() {
connect_shortcut(ui->action_Insert_Coin, SET_INP_SC_INSERT_COIN, SLOT(s_insert_coin()));
connect_shortcut(ui->action_Switch_sides, SET_INP_SC_SWITCH_SIDES, SLOT(s_disk_side()));
connect_shortcut(ui->action_Eject_Insert_Disk, SET_INP_SC_EJECT_DISK, SLOT(s_eject_disk()));
connect_shortcut(ui->action_Start_Stop_record_WAV, SET_INP_SC_WAV, SLOT(s_start_stop_wave()));
connect_shortcut(ui->action_Start_Stop_WAV_recording, SET_INP_SC_WAV, SLOT(s_start_stop_wave()));
connect_shortcut(ui->action_Fullscreen, SET_INP_SC_FULLSCREEN, SLOT(s_set_fullscreen()));
connect_shortcut(ui->action_Pause, SET_INP_SC_PAUSE, SLOT(s_pause()));
connect_shortcut(ui->action_Fast_Forward, SET_INP_SC_FAST_FORWARD, SLOT(s_fast_forward()));
Expand Down Expand Up @@ -1451,7 +1449,7 @@ void mainWindow::connect_menu_signals() {
connect_action(ui->action_Disk_4_side_B, 7, SLOT(s_disk_side()));
connect_action(ui->action_Switch_sides, 0xFFF, SLOT(s_disk_side()));
connect_action(ui->action_Eject_Insert_Disk, SLOT(s_eject_disk()));
connect_action(ui->action_Start_Stop_record_WAV, SLOT(s_start_stop_wave()));
connect_action(ui->action_Start_Stop_WAV_recording, SLOT(s_start_stop_wave()));
connect_action(ui->action_Fullscreen, SLOT(s_set_fullscreen()));
connect_action(ui->action_Pause, SLOT(s_pause()));
connect_action(ui->action_Fast_Forward, SLOT(s_fast_forward()));
Expand Down Expand Up @@ -1927,7 +1925,7 @@ void mainWindow::s_start_stop_wave() {

emu_pause(FALSE);
} else {
wave_close();
wave_close();
}
update_menu_nes();
}
Expand Down Expand Up @@ -2357,6 +2355,7 @@ void mainWindow::s_set_samplerate() {
}

emu_pause(TRUE);
wave_close();
cfg->samplerate = samplerate;
snd_playback_start();
gui_update();
Expand All @@ -2370,6 +2369,7 @@ void mainWindow::s_set_channels() {
}

emu_pause(TRUE);
wave_close();
cfg->channels_mode = channels;
snd_playback_start();
gui_update();
Expand Down Expand Up @@ -2709,7 +2709,7 @@ void mainWindow::s_shcjoy_read_timer() {
ui->action_Eject_Insert_Disk->trigger();
break;
case SET_INP_SC_WAV:
ui->action_Start_Stop_record_WAV->trigger();
ui->action_Start_Stop_WAV_recording->trigger();
break;
case SET_INP_SC_FULLSCREEN:
ui->action_Fullscreen->trigger();
Expand Down
2 changes: 1 addition & 1 deletion src/gui/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ static const _settings inp_cfg[] = {
{uL("shortcuts"), uL("insert coin"), uL("8,NULL"), NULL, NULL, {0, NULL}},
{uL("shortcuts"), uL("switch sides"), uL("Alt+S,NULL"), NULL, NULL, {0, NULL}},
{uL("shortcuts"), uL("eject disk"), uL("Alt+E,NULL"), NULL, NULL, {0, NULL}},
{uL("shortcuts"), uL("start/stop record WAV"), uL("Alt+V,NULL"), NULL, NULL, {0, NULL}},
{uL("shortcuts"), uL("start/stop WAV recording"), uL("Alt+V,NULL"), NULL, NULL, {0, NULL}},
{uL("shortcuts"), uL("video fullscreen"), uL("Alt+Return,NULL"), NULL, NULL, {0, NULL}},
{uL("shortcuts"), uL("pause"), uL("Pause,NULL"), NULL, NULL, {0, NULL}},
{uL("shortcuts"), uL("fast forward"), uL("Tab,NULL"), NULL, NULL, {0, NULL}},
Expand Down

0 comments on commit d553a51

Please sign in to comment.