2 Calf Box, an open source musical instrument.
3 Copyright (C) 2010-2013 Krzysztof Foltman
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 struct cbox_adhoc_pattern
*cbox_adhoc_pattern_new(struct cbox_engine
*engine
, int id
, struct cbox_midi_pattern
*pattern
)
24 struct cbox_adhoc_pattern
*ap
= calloc(1, sizeof(struct cbox_adhoc_pattern
));
26 ap
->pattern
= pattern
;
27 ap
->pattern_playback
= cbox_midi_pattern_playback_new(pattern
);
28 ap
->master
= cbox_master_new(engine
);
29 cbox_midi_playback_active_notes_init(&ap
->active_notes
);
30 cbox_midi_clip_playback_init(&ap
->playback
, &ap
->active_notes
, ap
->master
);
31 cbox_midi_buffer_init(&ap
->output_buffer
);
33 ap
->completed
= FALSE
;
38 void cbox_adhoc_pattern_render(struct cbox_adhoc_pattern
*ap
, int offset
, int nsamples
)
42 cbox_midi_playback_active_notes_release(&ap
->active_notes
, &ap
->output_buffer
);
45 if (ap
->playback
.pos
>= ap
->playback
.pattern
->event_count
)
47 cbox_midi_clip_playback_render(&ap
->playback
, &ap
->output_buffer
, offset
, nsamples
);
50 void cbox_adhoc_pattern_destroy(struct cbox_adhoc_pattern
*ap
)
52 // XXXKF decide on pattern ownership and general object lifetime issues
53 cbox_midi_pattern_playback_destroy(ap
->playback
.pattern
);
54 cbox_master_destroy(ap
->master
);