~ubuntu-branches/debian/sid/bristol/sid

« back to all changes in this revision

Viewing changes to brighton/brighton.c

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2011-02-15 02:54:23 UTC
  • mfrom: (13.1.6 experimental)
  • Revision ID: james.westby@ubuntu.com-20110215025423-g8hcla5gyl08mae3
Tags: 0.60.8-2
* Upload to unstable.
* Relax JACK's build-deps to let this build in sid.

Show diffs side-by-side

added added

removed removed

Lines of Context:
98
98
 
99
99
void *eventMgr();
100
100
 
101
 
int readMe = 0;
102
 
int gmc = 0;
103
 
int opacity = 60;
104
 
int gs = 1;
105
 
int nar = 0;
106
 
int azoom = 0;
107
 
int quality = 6;
108
 
int deswidth = -1;
109
 
float scale = 1.0;
110
 
float antialias = 0.0;
111
 
int aliastype = 0;
112
 
int library = 1;
113
 
int dcTimeout = 500000;
114
 
int sampleRate = 44100;
115
 
int sampleCount = 256;
116
 
int mwt = 50000;
117
 
int activeSense = 2000;
118
 
int activeSensePeriod = 15000;
119
 
int bwflags = BRIGHTON_POST_WINDOW;
120
 
int rlflags = BRIGHTON_SET_RAISE|BRIGHTON_SET_LOWER;
121
 
int nrpcc = BRIGHTON_NRP_COUNT;
122
 
int cli = 0;
123
 
int cli_fd[2];
 
101
static int readMe = 0;
 
102
static int gmc = 0;
 
103
static int opacity = 60;
 
104
static int gs = 1;
 
105
static int nar = 0;
 
106
static int azoom = 0;
 
107
static int quality = 6;
 
108
static int deswidth = -1;
 
109
static float scale = 1.0;
 
110
static float antialias = 0.0;
 
111
static int aliastype = 0;
 
112
static int library = 1;
 
113
static int dcTimeout = 500000;
 
114
static int sampleRate = 44100;
 
115
static int sampleCount = 256;
 
116
static int mwt = 50000;
 
117
static int activeSense = 2000;
 
118
static int activeSensePeriod = 15000;
 
119
static int bwflags = BRIGHTON_POST_WINDOW;
 
120
static int rlflags = BRIGHTON_SET_RAISE|BRIGHTON_SET_LOWER;
 
121
static int nrpcc = BRIGHTON_NRP_COUNT;
 
122
static int cli = 0;
 
123
static int cli_fd[2];
124
124
 
125
 
static char *BRISTOL_DEF_HOST = "localhost";
 
125
static char defaultcdev[16];
126
126
 
127
127
extern int vuInterval;
128
128
void printBrightonHelp(int);
160
160
}
161
161
 
162
162
static void
 
163
printSummaryText()
 
164
{
 
165
        int i;
 
166
 
 
167
        for (i = 0 ; i < BRISTOL_SYNTHCOUNT; i++)
 
168
        {
 
169
                if ((synthesisers[i] != NULL)
 
170
                        && (synthesisers[i]->name != NULL)
 
171
                        && (synthesisers[i]->name[0] != '\0'))
 
172
                        printf("%s ", synthesisers[i]->name);
 
173
        }
 
174
        printf("\n");
 
175
}
 
176
 
 
177
static void
163
178
brightonFindEmulation(int argc, char **argv)
164
179
{
165
180
        int argCount, i, found = -1;
174
189
                        if (synthesisers[i] == NULL)
175
190
                                continue;
176
191
 
 
192
                        /* Check for a few aliases */
 
193
                        if (strcmp("-2600", argv[argCount]) == 0)
 
194
                                found = global.synths->synthtype = BRISTOL_2600;
 
195
                        if (strcmp("-mg1", argv[argCount]) == 0)
 
196
                                found = global.synths->synthtype = BRISTOL_REALISTIC;
 
197
                        if (strcmp("-bme700", argv[argCount]) == 0)
 
198
                                found = global.synths->synthtype = BRISTOL_BME700;
 
199
                        if (strcmp("-pro10", argv[argCount]) == 0)
 
200
                                found = global.synths->synthtype = BRISTOL_PROPHET10;
 
201
                        if (strcmp("-pro52", argv[argCount]) == 0)
 
202
                                found = global.synths->synthtype = BRISTOL_PRO52;
 
203
                        if ((strcmp("-poly6", argv[argCount]) == 0)
 
204
                                || (strcmp("-polysix", argv[argCount]) == 0))
 
205
                                found = global.synths->synthtype = BRISTOL_POLY6;
 
206
                        if ((strcmp("-memmoog", argv[argCount]) == 0)
 
207
                                || (strcmp("-memorymoog", argv[argCount]) == 0))
 
208
                                found = global.synths->synthtype = BRISTOL_MEMMOOG;
 
209
 
177
210
                        if ((strcmp("-emulate", argv[argCount]) == 0)
178
211
                                && (argCount < (argc - 1)))
179
212
                        {
195
228
 
196
229
        if (found > 0)
197
230
                printf("%s emulation defaults:\n", synthesisers[i]->name);
198
 
        else
 
231
        else {
199
232
                printf("emulation defaults:\n");
 
233
        }
200
234
 
201
 
        if ((global.synths->voices = synthesisers[i]->emulate.voices)
202
 
                < 0)
 
235
        if ((global.synths->voices = synthesisers[i]->emulate.voices) < 0)
203
236
        {
204
237
                printf("    -voices  %i\n", BRISTOL_VOICECOUNT);
205
238
                global.synths->voices = BRISTOL_VOICECOUNT;
245
278
        int argCount = 1, i, j, logtype = BRISTOL_LOG_BRIGHTON;
246
279
        pthread_t emgrThread, logthread;
247
280
        char appname[65], *devname = defname;
 
281
        int reqW = 0, reqH = 0, reqX = 0, reqY = 0;
248
282
 
249
283
        signal(SIGINT, cleanupBristol);
250
284
        signal(SIGPIPE, cleanupBristolQuietly);
273
307
        global.synths->notepref = BRIGHTON_POLYPHONIC;
274
308
        global.synths->notetrig = 0;
275
309
        global.synths->win = NULL;
276
 
        global.synths->flags = REQ_FORWARD|REQ_LOCAL_FORWARD|REQ_REMOTE_FORWARD;
 
310
        global.synths->flags =
 
311
                REQ_FORWARD|REQ_LOCAL_FORWARD|REQ_REMOTE_FORWARD|NO_LATCHING_KEYS;
277
312
        global.port = 5028;
278
 
        global.host = BRISTOL_DEF_HOST;
 
313
        snprintf(defaultcdev, 16, "localhost");
 
314
        global.host = defaultcdev;
279
315
 
280
316
        memset(synthesisers, 0, sizeof(synthesisers));
281
317
 
351
387
                exit(0);
352
388
        }
353
389
 
 
390
        if ((argc > 1) && (strcmp(argv[1], "--summary") == 0))
 
391
        {
 
392
                printSummaryText();
 
393
                exit(0);
 
394
        }
354
395
        if ((argc > 1) && (strcmp(argv[1], "-summary") == 0))
355
396
        {
356
 
                printf("%s", summarytext);
 
397
                printf("%s\n", summarytext);
357
398
                exit(0);
358
399
        }
359
400
 
489
530
                        continue;
490
531
                }
491
532
 
 
533
                if (((strcmp(argv[argCount], "-geometry") == 0)
 
534
                        || (strcmp(argv[argCount], "-geom") == 0))
 
535
                        && (argCount < argc))
 
536
                {
 
537
                        int i = 0;
 
538
                        char *yp;
 
539
 
 
540
                        argCount++;
 
541
 
 
542
                        /*
 
543
                         * We want WxH+x+y
 
544
                         * If we only have +-x+-y then don't apply w.h
 
545
                         * If we have H+x+y then use H as a width and use it to scale
 
546
                         * the image to a given bitmap. If we have W+H then automatically
 
547
                         * set -ar.
 
548
                         */
 
549
 
 
550
                        /*
 
551
                         * Start looking for width
 
552
                         */
 
553
                        while ((argv[argCount][i] != '-')
 
554
                                && (argv[argCount][i] != '+')
 
555
                                && (argv[argCount][i] != '\0')
 
556
                                && (argv[argCount][i] != 'x'))
 
557
                        {
 
558
                                reqW = reqW * 10 + argv[argCount][i] - 48;
 
559
                                i++;
 
560
                        }
 
561
 
 
562
                        if (argv[argCount][i] == 'x')
 
563
                                i++;
 
564
 
 
565
                        /* Look for height */
 
566
                        while ((argv[argCount][i] != '-')
 
567
                                && (argv[argCount][i] != '+')
 
568
                                && (argv[argCount][i] != '\0')
 
569
                                && (argv[argCount][i] != 'x'))
 
570
                        {
 
571
                                reqH = reqH * 10 + argv[argCount][i] - 48;
 
572
                                i++;
 
573
                        }
 
574
 
 
575
                        /* Take an X if it is available */
 
576
                        if (argv[argCount][i] != '\0')
 
577
                                reqX = atoi(&argv[argCount][i]);
 
578
                        if ((reqX == 0) && (argv[argCount][i] == '-'))
 
579
                                reqX = -1;
 
580
 
 
581
                        if ((yp = strchr(&argv[argCount][++i], '+')))
 
582
                                reqY = atoi(yp);
 
583
                        else if ((yp = strchr(&argv[argCount][++i], '-')))
 
584
                                reqY = atoi(yp);
 
585
                        if ((reqY == 0) && (argv[argCount][i] == '-'))
 
586
                                reqY = -1;
 
587
                }
 
588
 
492
589
                if (strcmp(argv[argCount], "-iconify") == 0)
493
590
                        bwflags &= ~BRIGHTON_POST_WINDOW;
494
591
 
793
890
                }
794
891
/* Need to add in PitchWheel Depth (done), Find and Coarse tuning*/
795
892
 
 
893
                if (strcmp(argv[argCount], "-neutral") == 0)
 
894
                        global.synths->location = -1;
 
895
 
796
896
                if ((strcmp(argv[argCount], "-load") == 0) && (argCount < argc))
797
897
                {
798
898
                        if (argCount < argc)
860
960
 
861
961
                if ((strcmp(argv[argCount], "-voices") == 0) && (argCount < argc))
862
962
                {
863
 
                        if (((global.synths->voices = atoi(argv[argCount + 1])) == 1)
 
963
                        if ((atoi(argv[argCount + 1]) > 0)
 
964
                                && ((global.synths->voices = atoi(argv[argCount + 1])) == 1)
864
965
                                && (global.synths->notepref == BRIGHTON_POLYPHONIC))
865
966
                                global.synths->notepref = BRIGHTON_HNP;
 
967
                        else if (atoi(argv[argCount + 1]) == 0)
 
968
                                global.synths->voices = BRISTOL_VOICECOUNT;
866
969
                        argCount++;
867
970
                }
868
971
 
942
1045
                        global.synths->flags |= NO_KEYTRACK;
943
1046
                        argCount++;
944
1047
                }
 
1048
                if (strcmp(argv[argCount], "-keytoggle") == 0)
 
1049
                        global.synths->flags &= ~NO_LATCHING_KEYS;
945
1050
 
946
1051
                if (strcmp(argv[argCount], "-port") == 0)
947
1052
                {
951
1056
                }
952
1057
 
953
1058
                if (strcmp(argv[argCount], "-host") == 0)
954
 
                        global.host = argv[++argCount];
 
1059
                        snprintf(defaultcdev, 16, "%s", argv[++argCount]);
955
1060
 
956
1061
                if (strcmp(argv[argCount], "-window") == 0)
957
1062
                        synthesisers[global.synths->synthtype]->flags ^= BRIGHTON_WINDOW;
1038
1143
                if (strcmp(argv[argCount], "-cs80") == 0)
1039
1144
                {
1040
1145
                        global.synths->synthtype = BRISTOL_CS80;
 
1146
                        printf("The CS80 is not an operational emulator\n");
1041
1147
                        global.libtest = 1;
1042
1148
                }
1043
1149
 
1056
1162
                if (strcmp(argv[argCount], "-sampler") == 0)
1057
1163
                {
1058
1164
                        global.synths->synthtype = BRISTOL_SAMPLER;
 
1165
                        printf("The sampler is not an operational emulator\n");
1059
1166
                        global.libtest = 1;
1060
1167
                }
1061
1168
 
1076
1183
                if (strcmp(argv[argCount], "-mixer") == 0)
1077
1184
                {
1078
1185
                        global.libtest = 1;
 
1186
                        printf("The bristol mixer is not an operational emulator\n");
1079
1187
                        global.synths->synthtype = BRISTOL_MIXER;
1080
1188
                }
1081
1189
 
1141
1249
                if (strcmp(argv[argCount], "-ms20") == 0)
1142
1250
                {
1143
1251
                        global.synths->synthtype = BRISTOL_MS20;
 
1252
                        printf("The ms20 is not an operational emulator\n");
1144
1253
                        global.libtest = 1;
1145
1254
                }
1146
1255
 
1214
1323
                        || (strcmp(argv[argCount], "-aks") == 0))
1215
1324
                {
1216
1325
                        global.synths->synthtype = BRISTOL_SAKS;
 
1326
                        printf("AKS is not an operational emulator\n");
1217
1327
                        global.libtest = 1;
1218
1328
                }
1219
1329
 
1221
1331
                        || (strcmp(argv[argCount], "-quantum") == 0))
1222
1332
                {
1223
1333
                        global.synths->synthtype = BRISTOL_GRANULAR;
 
1334
                        printf("The granular is not an operational emulator\n");
1224
1335
                        global.libtest = 1;
1225
1336
                }
1226
1337
 
1345
1456
                argCount++;
1346
1457
        }
1347
1458
 
 
1459
        if (strncmp("unix:", defaultcdev, 5) == 0)
 
1460
        {
 
1461
                if (strlen(defaultcdev) == 5)
 
1462
                        snprintf(defaultcdev, 16, "unix:%i", global.port);
 
1463
                else
 
1464
                        global.port = atoi(&defaultcdev[5]);
 
1465
        }
 
1466
 
1348
1467
#ifndef BRIGHTON_HAS_X11
1349
1468
        /* Reverse the window logic */
1350
1469
        synthesisers[global.synths->synthtype]->flags ^= BRIGHTON_WINDOW;
1351
1470
#endif
1352
1471
 
 
1472
        if (reqW)
 
1473
        {
 
1474
                /* Width is a scaler */
 
1475
                float scale;
 
1476
 
 
1477
                scale = ((float) reqW) / synthesisers[global.synths->synthtype]->width;
 
1478
 
 
1479
                /* Have been given some width value */
 
1480
                if (reqH)
 
1481
                {
 
1482
                        nar = 1;
 
1483
                        synthesisers[global.synths->synthtype]->width = reqW;
 
1484
                        synthesisers[global.synths->synthtype]->height = reqH;
 
1485
                } else {
 
1486
                        synthesisers[global.synths->synthtype]->width = reqW;
 
1487
                        synthesisers[global.synths->synthtype]->height *= scale;
 
1488
                }
 
1489
 
 
1490
                if ((scale > 1.1) || (scale < 0.9))
 
1491
                        aliastype = 5;
 
1492
                else
 
1493
                        aliastype = 0;
 
1494
        }
 
1495
 
1353
1496
        {
1354
1497
                char statfile[1024];
1355
1498
                struct stat statres;
1462
1605
        synthesisers[global.synths->synthtype]->name = appname;
1463
1606
        if ((global.synths->win =
1464
1607
                brightonInterface(synthesisers[global.synths->synthtype],
1465
 
                        quality, library, aliastype, antialias, gs)) == NULL)
 
1608
                        quality, library, aliastype, antialias, gs, reqX, reqY)) == NULL)
1466
1609
        {
1467
1610
                printf("could not create window\n");
1468
1611
                exit(-1);
1570
1713
        brightonReadConfiguration(global.synths->win,
1571
1714
                synthesisers[global.synths->synthtype],
1572
1715
                global.synths->midichannel,
1573
 
                synthesisers[global.synths->synthtype]->name);
 
1716
                synthesisers[global.synths->synthtype]->name,
 
1717
                NULL);
1574
1718
 
1575
1719
        if (bristolMidiSendMsg(global.controlfd, global.synths->sid,
1576
1720
                BRISTOL_ACTIVE_SENSE, 0, activeSense == 0? 0:16383) != 0)