Skip to content

Commit

Permalink
Merge branch 'purr-data-devname-prefs'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Wilkes committed Jan 3, 2023
2 parents b3ae615 + 1c978d8 commit fce5125
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions pd/src/s_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,14 @@ void sys_loadpreferences( void)
break;
if (sscanf(prefbuf, "%d %d", &audioindev[i], &chindev[i]) < 2)
break;
/* AG: If we have a name for the device, find the proper device
index in case that there was a change to the device list
between invocations. */
sprintf(keybuf, "audioindevname%d", i+1);
if (sys_getpreference(keybuf, prefbuf, MAXPDSTRING)) {
int d = sys_audiodevnametonumber(0, prefbuf);
if (d >= 0) audioindev[i] = d;
}
naudioindev++;
}
/* if no preferences at all, set -1 for default behavior */
Expand All @@ -570,6 +578,14 @@ void sys_loadpreferences( void)
break;
if (sscanf(prefbuf, "%d %d", &audiooutdev[i], &choutdev[i]) < 2)
break;
/* AG: If we have a name for the device, find the proper device
index in case that there was a change to the device list
between invocations. */
sprintf(keybuf, "audiooutdevname%d", i+1);
if (sys_getpreference(keybuf, prefbuf, MAXPDSTRING)) {
int d = sys_audiodevnametonumber(1, prefbuf);
if (d >= 0) audiooutdev[i] = d;
}
naudiooutdev++;
}
if (naudiooutdev == 0)
Expand Down Expand Up @@ -609,6 +625,14 @@ void sys_loadpreferences( void)
break;
if (sscanf(prefbuf, "%d", &midiindev[i]) < 1)
break;
/* AG: If we have a name for the device, find the proper device
index in case that there was a change to the device list
between invocations. */
sprintf(keybuf, "midiindevname%d", i+1);
if (sys_getpreference(keybuf, prefbuf, MAXPDSTRING)) {
int d = sys_mididevnametonumber(0, prefbuf);
if (d >= 0) midiindev[i] = d;
}
nmidiindev++;
}
}
Expand All @@ -630,6 +654,14 @@ void sys_loadpreferences( void)
break;
if (sscanf(prefbuf, "%d", &midioutdev[i]) < 1)
break;
/* AG: If we have a name for the device, find the proper device
index in case that there was a change to the device list
between invocations. */
sprintf(keybuf, "midioutdevname%d", i+1);
if (sys_getpreference(keybuf, prefbuf, MAXPDSTRING)) {
int d = sys_mididevnametonumber(1, prefbuf);
if (d >= 0) midioutdev[i] = d;
}
nmidioutdev++;
}
}
Expand Down Expand Up @@ -750,6 +782,14 @@ void glob_savepreferences(t_pd *dummy)
sprintf(buf1, "audioindev%d", i+1);
sprintf(buf2, "%d %d", audioindev[i], chindev[i]);
sys_putpreference(buf1, buf2);
/* AG: If we have a name for the device, store it with the device
index, so that we can find the proper device index after a change
to the device list between invocations. */
sys_audiodevnumbertoname(0, audioindev[i], buf2, MAXPDSTRING);
if (*buf2) {
sprintf(buf1, "audioindevname%d", i+1);
sys_putpreference(buf1, buf2);
}
}
sys_putpreference("noaudioout", (naudiooutdev <= 0 ? "True" : "False"));
/* AG: naudioout key */
Expand All @@ -760,6 +800,14 @@ void glob_savepreferences(t_pd *dummy)
sprintf(buf1, "audiooutdev%d", i+1);
sprintf(buf2, "%d %d", audiooutdev[i], choutdev[i]);
sys_putpreference(buf1, buf2);
/* AG: If we have a name for the device, store it with the device
index, so that we can find the proper device index after a change
to the device list between invocations. */
sys_audiodevnumbertoname(1, audiooutdev[i], buf2, MAXPDSTRING);
if (*buf2) {
sprintf(buf1, "audiooutdevname%d", i+1);
sys_putpreference(buf1, buf2);
}
}

sprintf(buf1, "%d", advance);
Expand Down Expand Up @@ -788,6 +836,14 @@ void glob_savepreferences(t_pd *dummy)
sprintf(buf1, "midiindev%d", i+1);
sprintf(buf2, "%d", midiindev[i]);
sys_putpreference(buf1, buf2);
/* AG: If we have a name for the device, store it with the device
index, so that we can find the proper device index after a change
to the device list between invocations. */
sys_mididevnumbertoname(0, midiindev[i], buf2, MAXPDSTRING);
if (*buf2) {
sprintf(buf1, "midiindevname%d", i+1);
sys_putpreference(buf1, buf2);
}
}
sys_putpreference("nomidiout", (nmidioutdev <= 0 ? "True" : "False"));
/* AG: nmidiout */
Expand All @@ -798,6 +854,14 @@ void glob_savepreferences(t_pd *dummy)
sprintf(buf1, "midioutdev%d", i+1);
sprintf(buf2, "%d", midioutdev[i]);
sys_putpreference(buf1, buf2);
/* AG: If we have a name for the device, store it with the device
index, so that we can find the proper device index after a change
to the device list between invocations. */
sys_mididevnumbertoname(1, midioutdev[i], buf2, MAXPDSTRING);
if (*buf2) {
sprintf(buf1, "midioutdevname%d", i+1);
sys_putpreference(buf1, buf2);
}
}
/* file search path */

Expand Down

0 comments on commit fce5125

Please sign in to comment.