forked from m5evt/linhpsdr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmidi_dialog.c
100 lines (84 loc) · 2.87 KB
/
midi_dialog.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/* Copyright (C)
* 2020 - John Melton, G0ORX/N6LYT
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include <gtk/gtk.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <termios.h>
#include "discovered.h"
#include "bpsk.h"
#include "mode.h"
#include "filter.h"
#include "band.h"
#include "receiver.h"
#include "transmitter.h"
#include "receiver.h"
#include "wideband.h"
#include "adc.h"
#include "dac.h"
#include "radio.h"
#include "midi.h"
#include "midi_dialog.h"
static GtkWidget *filename;
static gboolean midi_enable_cb(GtkWidget *widget,gpointer data) {
RADIO *r=(RADIO *)data;
r->midi_enabled=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (widget));
if(r->midi_enabled) {
strcpy(r->midi_filename,gtk_entry_get_text(GTK_ENTRY(filename)));
int rc=MIDIstartup(r->midi_filename);
} else {
MIDIstop(r);
}
return TRUE;
}
static void debug_cb(GtkWidget *widget, gpointer data) {
RADIO *r=(RADIO *)data;
midi_debug=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (widget));
}
GtkWidget *create_midi_dialog(RADIO *r) {
int i;
int col=0;
int row=0;
GtkWidget *midi_frame=gtk_frame_new("MIDI");
GtkWidget *grid=gtk_grid_new();
gtk_grid_set_row_homogeneous(GTK_GRID(grid),FALSE);
gtk_grid_set_column_homogeneous(GTK_GRID(grid),FALSE);
gtk_grid_set_column_spacing(GTK_GRID(grid),5);
gtk_container_add(GTK_CONTAINER(midi_frame),grid);
row=0;
col=0;
GtkWidget *midi_enable_b=gtk_check_button_new_with_label("MIDI Enable");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (midi_enable_b), r->midi_enabled);
gtk_grid_attach(GTK_GRID(grid),midi_enable_b,col,row,1,1);
g_signal_connect(midi_enable_b,"toggled",G_CALLBACK(midi_enable_cb),r);
row++;
col++;
filename=gtk_entry_new();
gtk_entry_set_width_chars(GTK_ENTRY(filename),strlen(r->midi_filename));
gtk_entry_set_text(GTK_ENTRY(filename),r->midi_filename);
gtk_grid_attach(GTK_GRID(grid),filename,col,row,1,1);
col=0;
row++;
GtkWidget *debug_b=gtk_check_button_new_with_label("MIDI Debug");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (debug_b), midi_debug);
gtk_grid_attach(GTK_GRID(grid),debug_b,col,row,1,1);
g_signal_connect(debug_b,"toggled",G_CALLBACK(debug_cb),r);
return midi_frame;
}