Lines Matching refs:mc

80 static void reset_all_controllers(midictl *mc, uint_fast8_t chan);
81 static void enter14(midictl *mc, uint_fast8_t chan, class c,
83 static uint_fast16_t read14(midictl *mc, uint_fast8_t chan, class c,
170 midictl_open(midictl *mc)
175 if (mc->lock == NULL)
177 if (NULL == mc->notify)
178 mc->notify = notify_no_one;
182 s->lock = mc->lock;
193 mc->store = s;
198 midictl_close(midictl *mc)
203 s = mc->store;
213 midictl_change(midictl *mc, uint_fast8_t chan, uint8_t *ctlval)
219 KASSERT(mutex_owned(mc->lock));
220 KASSERT(!mc->store->destroy);
230 if ( chan != mc->base_channel )
235 mc->notify(mc->cookie, MIDICTL_NOTES_OFF, chan, 0);
238 mc->notify(mc->cookie, MIDICTL_LOCAL, chan, ctlval[1]);
241 mc->notify(mc->cookie, MIDICTL_SOUND_OFF, chan, 0);
244 reset_all_controllers(mc, chan);
250 mc-> rpn &= ~0x7f;
251 mc-> rpn |= PN_SET | (0x7f & ctlval[1]);
252 mc->nrpn &= ~PN_SET;
255 mc-> rpn &= ~0x7fU<<7;
256 mc-> rpn |= PN_SET | (0x7f & ctlval[1])<<7;
257 mc->nrpn &= ~PN_SET;
260 mc->nrpn &= ~0x7f;
261 mc->nrpn |= PN_SET | (0x7f & ctlval[1]);
262 mc-> rpn &= ~PN_SET;
265 mc->nrpn &= ~0x7fU<<7;
266 mc->nrpn |= PN_SET | (0x7f & ctlval[1])<<7;
267 mc-> rpn &= ~PN_SET;
275 if ( 0 == ( (mc->rpn ^ mc->nrpn) & PN_SET ) )
277 if ( mc->rpn & PN_SET ) {
278 key = mc->rpn;
281 key = mc->nrpn;
287 enter14(mc, chan, c, key, islsb, ctlval[1]);
305 enter14(mc, chan, c, key, islsb, ctlval[1]);
308 present = store_locate(mc->store, c, chan, key);
309 if ( !mc->accept_any_ctl_rpn ) {
312 val = store_extract(mc->store, c, chan, key);
316 store_update(mc->store, c, chan, key,
318 mc->notify(mc->cookie, MIDICTL_CTLR, chan, key);
321 present = store_locate(mc->store, c, chan, key);
322 if ( !mc->accept_any_ctl_rpn ) {
325 val = store_extract(mc->store, c, chan, key);
329 store_update(mc->store, c, chan, key,
331 mc->notify(mc->cookie, MIDICTL_CTLR, chan, key);
340 midictl_read(midictl *mc, uint_fast8_t chan, uint_fast8_t ctlr,
347 KASSERT(mutex_owned(mc->lock));
348 KASSERT(!mc->store->destroy);
354 present = store_locate(mc->store, c, chan, key);
356 !(C1_SET&(val = store_extract(mc->store, c, chan, key))) ) {
358 store_update(mc->store, c, chan, key, val);
362 present = store_locate(mc->store, c, chan, key);
364 !(C7_SET&(val = store_extract(mc->store, c, chan, key))) ) {
366 store_update(mc->store, c, chan, key, val);
371 return read14(mc, chan, c, key, dflt);
380 midictl_rpn_read(midictl *mc, uint_fast8_t chan, uint_fast16_t ctlr,
384 KASSERT(mutex_owned(mc->lock));
385 KASSERT(!mc->store->destroy);
387 return read14(mc, chan, RPN, ctlr, dflt);
391 midictl_nrpn_read(midictl *mc, uint_fast8_t chan, uint_fast16_t ctlr,
395 KASSERT(mutex_owned(mc->lock));
396 KASSERT(!mc->store->destroy);
398 return read14(mc, chan, NRPN, ctlr, dflt);
402 reset_all_controllers(midictl *mc, uint_fast8_t chan)
408 KASSERT(mutex_owned(mc->lock));
437 present = store_locate(mc->store, c, chan, key);
440 store_update(mc->store, c, chan, key, 0); /* no C*SET */
443 mc->notify(mc->cookie, MIDICTL_RESET, chan, 0);
447 enter14(midictl *mc, uint_fast8_t chan, class c, uint_fast16_t key,
453 KASSERT(mutex_owned(mc->lock));
455 present = store_locate(mc->store, c, chan, key);
456 stval = (present) ? store_extract(mc->store, c, chan, key) : 0;
458 if ( !((NRPN==c)? mc->accept_any_nrpn: mc->accept_any_ctl_rpn) )
465 store_update(mc->store, c, chan, key, stval);
466 mc->notify(mc->cookie, CTL14 == c ? MIDICTL_CTLR
472 read14(midictl *mc, uint_fast8_t chan, class c, uint_fast16_t key,
478 KASSERT(mutex_owned(mc->lock));
480 present = store_locate(mc->store, c, chan, key);
484 val = store_extract(mc->store, c, chan, key);
498 store_update(mc->store, c, chan, key, val);