mirror of
https://github.com/cookiengineer/audacity
synced 2026-01-11 15:15:57 +01:00
Extensive changes to improve NoteTrack display and (some) editing, NoteTrack playback via MIDI, and Midi-to-Audio alignment.
This commit is contained in:
@@ -8,13 +8,13 @@
|
||||
#define INPUT_BUFFER_SIZE 100
|
||||
#define OUTPUT_BUFFER_SIZE 0
|
||||
#define DRIVER_INFO NULL
|
||||
#define TIME_PROC ((long (*)(void *)) Pt_Time)
|
||||
#define TIME_PROC ((int32_t (*)(void *)) Pt_Time)
|
||||
#define TIME_INFO NULL
|
||||
#define TIME_START Pt_Start(1, 0, 0) /* timer started w/millisecond accuracy */
|
||||
|
||||
#define STRING_MAX 80 /* used for console input */
|
||||
|
||||
long latency = 0;
|
||||
int32_t latency = 0;
|
||||
|
||||
/* crash the program to test whether midi ports are closed */
|
||||
/**/
|
||||
@@ -87,10 +87,10 @@ void main_test_input(unsigned int somethingStupid) {
|
||||
if (length > 0) {
|
||||
printf("Got message %d: time %ld, %2lx %2lx %2lx\n",
|
||||
i,
|
||||
buffer[0].timestamp,
|
||||
Pm_MessageStatus(buffer[0].message),
|
||||
Pm_MessageData1(buffer[0].message),
|
||||
Pm_MessageData2(buffer[0].message));
|
||||
(long) buffer[0].timestamp,
|
||||
(long) Pm_MessageStatus(buffer[0].message),
|
||||
(long) Pm_MessageData1(buffer[0].message),
|
||||
(long) Pm_MessageData2(buffer[0].message));
|
||||
i++;
|
||||
} else {
|
||||
assert(0);
|
||||
@@ -116,7 +116,7 @@ void main_test_input(unsigned int somethingStupid) {
|
||||
void main_test_output() {
|
||||
PmStream * midi;
|
||||
char line[80];
|
||||
long off_time;
|
||||
int32_t off_time;
|
||||
int chord[] = { 60, 67, 76, 83, 90 };
|
||||
#define chord_size 5
|
||||
PmEvent buffer[chord_size];
|
||||
@@ -139,7 +139,7 @@ void main_test_output() {
|
||||
(latency == 0 ? NULL : TIME_PROC),
|
||||
(latency == 0 ? NULL : TIME_INFO),
|
||||
latency);
|
||||
printf("Midi Output opened with %ld ms latency.\n", latency);
|
||||
printf("Midi Output opened with %ld ms latency.\n", (long) latency);
|
||||
|
||||
/* output note on/off w/latency offset; hold until user prompts */
|
||||
printf("ready to send program 1 change... (type RETURN):");
|
||||
@@ -230,7 +230,7 @@ void main_test_both()
|
||||
TIME_PROC,
|
||||
TIME_INFO,
|
||||
latency);
|
||||
printf("Midi Output opened with %ld ms latency.\n", latency);
|
||||
printf("Midi Output opened with %ld ms latency.\n", (long) latency);
|
||||
/* open input device */
|
||||
Pm_OpenInput(&midi,
|
||||
in,
|
||||
@@ -253,11 +253,11 @@ void main_test_both()
|
||||
if (length > 0) {
|
||||
Pm_Write(midiOut, buffer, 1);
|
||||
printf("Got message %d: time %ld, %2lx %2lx %2lx\n",
|
||||
i,
|
||||
buffer[0].timestamp,
|
||||
Pm_MessageStatus(buffer[0].message),
|
||||
Pm_MessageData1(buffer[0].message),
|
||||
Pm_MessageData2(buffer[0].message));
|
||||
i,
|
||||
(long) buffer[0].timestamp,
|
||||
(long) Pm_MessageStatus(buffer[0].message),
|
||||
(long) Pm_MessageData1(buffer[0].message),
|
||||
(long) Pm_MessageData2(buffer[0].message));
|
||||
i++;
|
||||
} else {
|
||||
assert(0);
|
||||
@@ -301,7 +301,7 @@ void main_test_stream() {
|
||||
TIME_PROC,
|
||||
TIME_INFO,
|
||||
latency);
|
||||
printf("Midi Output opened with %ld ms latency.\n", latency);
|
||||
printf("Midi Output opened with %ld ms latency.\n", (long) latency);
|
||||
|
||||
/* output note on/off w/latency offset; hold until user prompts */
|
||||
printf("ready to send output... (type RETURN):");
|
||||
@@ -386,25 +386,32 @@ int main(int argc, char *argv[])
|
||||
int stream_test = 0;
|
||||
int latency_valid = FALSE;
|
||||
|
||||
if (sizeof(void *) == 8)
|
||||
printf("Apparently this is a 64-bit machine.\n");
|
||||
else if (sizeof(void *) == 4)
|
||||
printf ("Apparently this is a 32-bit machine.\n");
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-h") == 0) {
|
||||
show_usage();
|
||||
} else if (strcmp(argv[i], "-l") == 0 && (i + 1 < argc)) {
|
||||
i = i + 1;
|
||||
latency = atoi(argv[i]);
|
||||
printf("Latency will be %ld\n", latency);
|
||||
latency_valid = TRUE;
|
||||
printf("Latency will be %ld\n", (long) latency);
|
||||
latency_valid = TRUE;
|
||||
} else {
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
while (!latency_valid) {
|
||||
printf("Latency in ms: ");
|
||||
if (scanf("%ld", &latency) == 1) {
|
||||
latency_valid = TRUE;
|
||||
}
|
||||
}
|
||||
while (!latency_valid) {
|
||||
int lat; // declared int to match "%d"
|
||||
printf("Latency in ms: ");
|
||||
if (scanf("%d", &lat) == 1) {
|
||||
latency = (int32_t) lat; // coerce from "%d" to known size
|
||||
latency_valid = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* determine what type of test to run */
|
||||
printf("begin portMidi test...\n");
|
||||
@@ -413,7 +420,7 @@ int main(int argc, char *argv[])
|
||||
" 2: test input (fail w/assert)\n",
|
||||
" 3: test input (fail w/NULL assign)\n",
|
||||
" 4: test output\n 5: test both\n",
|
||||
" 6: stream test\n");
|
||||
" 6: stream test\n");
|
||||
while (n != 1) {
|
||||
n = scanf("%d", &i);
|
||||
fgets(line, STRING_MAX, stdin);
|
||||
|
||||
Reference in New Issue
Block a user