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

« back to all changes in this revision

Viewing changes to bin/bristolNRPgen.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:
1
 
 
2
 
/*
3
 
 *  Diverse Bristol audio routines.
4
 
 *  Copyright (c) by Nick Copeland <nickycopeland@hotmail.com> 1996,2010
5
 
 *
6
 
 *
7
 
 *   This program is free software; you can redistribute it and/or modify
8
 
 *   it under the terms of the GNU General Public License as published by
9
 
 *   the Free Software Foundation; either version 3 of the License, or
10
 
 *   (at your option) any later version.
11
 
 *
12
 
 *   This program is distributed in the hope that it will be useful,
13
 
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
 *   GNU General Public License for more details.
16
 
 *
17
 
 *   You should have received a copy of the GNU General Public License
18
 
 *   along with this program; if not, see <http://www.gnu.org/licenses/>.
19
 
 *
20
 
 */
21
 
 
22
 
#include <stdlib.h>
23
 
#include "bristol.h"
24
 
#include "bristolmidi.h"
25
 
 
26
 
extern int bristolPressureEvent();
27
 
 
28
 
int rate = 100000;
29
 
 
30
 
void
31
 
sendOnePressure(int mh, int client, int value)
32
 
{
33
 
        bristolPressureEvent(mh, client, 0, value);
34
 
}
35
 
 
36
 
void
37
 
sendOneNRP(int mh, int client, int nrp, int value)
38
 
{
39
 
        int cc, cf, vc, vf;
40
 
 
41
 
        cc = (nrp >> 7) & 0x7f;
42
 
        cf = nrp & 0x7f;
43
 
        vc = (value >> 7) & 0x7f;
44
 
        vf = value & 0x7f;
45
 
 
46
 
//      printf("sending %i %i %i %i\n", cc, cf, vc, vf);
47
 
 
48
 
        bristolMidiControl(mh, client, 0, MIDI_GM_NRP, cc);
49
 
        bristolMidiControl(mh, client, 0, MIDI_GM_NRP_F, cf);
50
 
        bristolMidiControl(mh, client, 0, MIDI_GM_DATAENTRY, vc);
51
 
        bristolMidiControl(mh, client, 0, MIDI_GM_DATAENTRY_F, vf);
52
 
        /* NULL */
53
 
//      bristolMidiControl(mh, client, 0, MIDI_GM_NRP, 127);
54
 
//      bristolMidiControl(mh, client, 0, MIDI_GM_NRP_F, 127);
55
 
}
56
 
 
57
 
void
58
 
sendManyNRP(int mh, int client, int nrp, int step, int delay)
59
 
{
60
 
        int count;
61
 
 
62
 
        for (count = 0; count < 16384; count+=128)
63
 
        {
64
 
                sendOneNRP(mh, client, 13, count);
65
 
                usleep(4000);
66
 
        }
67
 
        for (; count >= 0; count-=128)
68
 
        {
69
 
                sendOneNRP(mh, client, 13, count);
70
 
                usleep(4000);
71
 
        }
72
 
}
73
 
 
74
 
int
75
 
main(int argc, char *argv[])
76
 
{
77
 
        int mh, client = 128, argCount = 1;
78
 
        int count = 0x7fffffff;
79
 
        int cycle = 2;
80
 
 
81
 
        char *device = "bristolng";
82
 
 
83
 
        if ((argc > 1) && ((strcmp(argv[argCount], "-help") == 0)
84
 
                || (strcmp(argv[argCount], "--help") == 0)))
85
 
        {
86
 
                printf("%s: this is for bristol SQA testing, it only streams note events\n\
87
 
%s [-target <id = 128>] [-cycle <0-2>] [-count <n>] [-rate <ms>]\n",
88
 
                argv[0],
89
 
                argv[0]);
90
 
                exit(0);
91
 
        }
92
 
 
93
 
        while (argc > argCount) {
94
 
                if ((strcmp(argv[argCount], "-rate") == 0) && (argCount < argc))
95
 
                {
96
 
                        if ((rate = atoi(argv[argCount + 1])) < 0)
97
 
                                rate = 100;
98
 
                        rate *= 1000;
99
 
                        argCount++;
100
 
                }
101
 
 
102
 
                if ((strcmp(argv[argCount], "-target") == 0) && (argCount < argc))
103
 
                {
104
 
                        if ((client = atoi(argv[argCount + 1])) < 0)
105
 
                                client = 128;
106
 
                        argCount++;
107
 
                }
108
 
 
109
 
                if ((strcmp(argv[argCount], "-count") == 0) && (argCount < argc))
110
 
                {
111
 
                        if ((count = atoi(argv[argCount + 1])) < 0)
112
 
                                count = 0x7fffffff;
113
 
                        argCount++;
114
 
                }
115
 
 
116
 
                if ((strcmp(argv[argCount], "-cycle") == 0) && (argCount < argc))
117
 
                {
118
 
                        cycle = atoi(argv[argCount + 1]);
119
 
                        argCount++;
120
 
                }
121
 
 
122
 
                argCount++;
123
 
        }
124
 
 
125
 
        printf("Target %i, count %i, cycle %i\n", client, count, cycle);
126
 
 
127
 
        if ((mh = bristolMidiOpen(device, BRISTOL_CONN_SEQ|BRISTOL_WRONLY,
128
 
                -1, BRISTOL_REQ_ALL, NULL, NULL)) < 0)
129
 
        {
130
 
                printf("%s: could not open midi connection\n", argv[0]);
131
 
                exit(1);
132
 
        }
133
 
 
134
 
        sendOnePressure(mh, client, 64);
135
 
 
136
 
return(0);
137
 
        sendOneNRP(mh, client, 13, 1);
138
 
 
139
 
        sendManyNRP(mh, client, 13, 256, 1000);
140
 
        sendManyNRP(mh, client, 13, 256, 1000);
141
 
        sendManyNRP(mh, client, 13, 256, 1000);
142
 
        sendManyNRP(mh, client, 13, 256, 1000);
143
 
        sendManyNRP(mh, client, 13, 256, 1000);
144
 
        sendManyNRP(mh, client, 13, 256, 1000);
145
 
        sendManyNRP(mh, client, 13, 256, 1000);
146
 
        sendManyNRP(mh, client, 13, 256, 1000);
147
 
 
148
 
        exit(0);
149
 
}
150