mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-17 08:01:12 +02:00
Extensive changes to improve NoteTrack display and (some) editing, NoteTrack playback via MIDI, and Midi-to-Audio alignment.
This commit is contained in:
@@ -73,7 +73,7 @@ int active = FALSE;
|
||||
int monitor = FALSE;
|
||||
int midi_thru = TRUE;
|
||||
|
||||
long transpose;
|
||||
int transpose;
|
||||
PmStream *midi_in;
|
||||
PmStream *midi_out;
|
||||
|
||||
@@ -94,7 +94,7 @@ void process_midi(PtTimestamp timestamp, void *userData)
|
||||
{
|
||||
PmError result;
|
||||
PmEvent buffer; /* just one message at a time */
|
||||
long msg;
|
||||
int32_t msg;
|
||||
|
||||
/* do nothing until initialization completes */
|
||||
if (!active)
|
||||
@@ -127,7 +127,7 @@ void process_midi(PtTimestamp timestamp, void *userData)
|
||||
do {
|
||||
result = Pm_Poll(midi_in);
|
||||
if (result) {
|
||||
long status, data1, data2;
|
||||
int status, data1, data2;
|
||||
if (Pm_Read(midi_in, &buffer, 1) == pmBufferOverflow)
|
||||
continue;
|
||||
if (midi_thru)
|
||||
@@ -173,7 +173,7 @@ void exit_with_message(char *msg)
|
||||
int main()
|
||||
{
|
||||
int id;
|
||||
long n;
|
||||
int32_t n;
|
||||
const PmDeviceInfo *info;
|
||||
char line[STRING_MAX];
|
||||
int spin;
|
||||
@@ -190,12 +190,12 @@ int main()
|
||||
|
||||
/* make the message queues */
|
||||
/* messages can be of any size and any type, but all messages in
|
||||
* a given queue must have the same size. We'll just use long's
|
||||
* a given queue must have the same size. We'll just use int32_t's
|
||||
* for our messages in this simple example
|
||||
*/
|
||||
midi_to_main = Pm_QueueCreate(32, sizeof(long));
|
||||
midi_to_main = Pm_QueueCreate(32, sizeof(int32_t));
|
||||
assert(midi_to_main != NULL);
|
||||
main_to_midi = Pm_QueueCreate(32, sizeof(long));
|
||||
main_to_midi = Pm_QueueCreate(32, sizeof(int32_t));
|
||||
assert(main_to_midi != NULL);
|
||||
|
||||
/* a little test of enqueue and dequeue operations. Ordinarily,
|
||||
@@ -263,7 +263,8 @@ int main()
|
||||
"Must terminate with [ENTER]");
|
||||
|
||||
while (!done) {
|
||||
long msg;
|
||||
int32_t msg;
|
||||
int input;
|
||||
int len;
|
||||
fgets(line, STRING_MAX, stdin);
|
||||
/* remove the newline: */
|
||||
@@ -284,7 +285,8 @@ int main()
|
||||
do {
|
||||
spin = Pm_Dequeue(midi_to_main, &msg);
|
||||
} while (spin == 0); /* spin */ ;
|
||||
printf("... pitch is %ld\n", msg);
|
||||
// convert int32_t to long for safe printing
|
||||
printf("... pitch is %ld\n", (long) msg);
|
||||
} else if (strcmp(line, "t") == 0) {
|
||||
/* reading midi_thru asynchronously could give incorrect results,
|
||||
e.g. if you type "t" twice before the midi thread responds to
|
||||
@@ -294,10 +296,11 @@ int main()
|
||||
printf("Setting THRU %s\n", (midi_thru ? "off" : "on"));
|
||||
msg = THRU_MSG;
|
||||
Pm_Enqueue(main_to_midi, &msg);
|
||||
} else if (sscanf(line, "%ld", &msg) == 1) {
|
||||
if (msg >= -127 && msg <= 127) {
|
||||
/* send transposition value */
|
||||
printf("Transposing by %ld\n", msg);
|
||||
} else if (sscanf(line, "%d", &input) == 1) {
|
||||
if (input >= -127 && input <= 127) {
|
||||
/* send transposition value, make sur */
|
||||
printf("Transposing by %d\n", input);
|
||||
msg = (int32_t) input;
|
||||
Pm_Enqueue(main_to_midi, &msg);
|
||||
} else {
|
||||
printf("Transposition must be within -127...127\n");
|
||||
|
Reference in New Issue
Block a user