3 |
* LinuxSampler - modular, streaming capable sampler * |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
* Copyright (C) 2005 - 2009 Christian Schoenebeck * |
* Copyright (C) 2005 - 2008 Christian Schoenebeck * |
7 |
* Copyright (C) 2009 Grigor Iliev * |
* Copyright (C) 2009 - 2012 Christian Schoenebeck and Grigor Iliev * |
8 |
|
* Copyright (C) 2013 - 2014 Christian Schoenebeck and Andreas Persson * |
9 |
* * |
* * |
10 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
11 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
68 |
bool bNotify; |
bool bNotify; |
69 |
}; |
}; |
70 |
struct program_change_command_t { |
struct program_change_command_t { |
71 |
uint8_t Program; |
uint32_t Program; |
72 |
EngineChannel* pEngineChannel; |
EngineChannel* pEngineChannel; |
73 |
}; |
}; |
74 |
// Attributes |
// Attributes |
197 |
Thread(true, false, 1, -2), |
Thread(true, false, 1, -2), |
198 |
pInstruments(pInstruments), |
pInstruments(pInstruments), |
199 |
DeletionNotificationQueue(4*MaxStreams), |
DeletionNotificationQueue(4*MaxStreams), |
200 |
ProgramChangeQueue(100) |
ProgramChangeQueue(512) |
201 |
{ |
{ |
202 |
CreationQueue = new RingBuffer<create_command_t,false>(4*MaxStreams); |
CreationQueue = new RingBuffer<create_command_t,false>(4*MaxStreams); |
203 |
DeletionQueue = new RingBuffer<delete_command_t,false>(4*MaxStreams); |
DeletionQueue = new RingBuffer<delete_command_t,false>(4*MaxStreams); |
383 |
* Tell the disk thread to do a program change on the specified |
* Tell the disk thread to do a program change on the specified |
384 |
* EngineChannel. |
* EngineChannel. |
385 |
*/ |
*/ |
386 |
int OrderProgramChange(uint8_t Program, EngineChannel* pEngineChannel) { |
int OrderProgramChange(uint32_t Program, EngineChannel* pEngineChannel) { |
387 |
program_change_command_t cmd; |
program_change_command_t cmd; |
388 |
cmd.Program = Program; |
cmd.Program = Program; |
389 |
cmd.pEngineChannel = pEngineChannel; |
cmd.pEngineChannel = pEngineChannel; |
504 |
} |
} |
505 |
|
|
506 |
// perform MIDI program change commands |
// perform MIDI program change commands |
507 |
while (ProgramChangeQueue.read_space() > 0) { |
if (ProgramChangeQueue.read_space() > 0) { |
508 |
program_change_command_t cmd; |
program_change_command_t cmd; |
509 |
ProgramChangeQueue.pop(&cmd); |
// skip all old ones, only process the latest one |
510 |
|
do { |
511 |
|
ProgramChangeQueue.pop(&cmd); |
512 |
|
} while (ProgramChangeQueue.read_space() > 0); |
513 |
cmd.pEngineChannel->ExecuteProgramChange(cmd.Program); |
cmd.pEngineChannel->ExecuteProgramChange(cmd.Program); |
514 |
} |
} |
515 |
|
|
516 |
RefillStreams(); // refill the most empty streams |
RefillStreams(); // refill the most empty streams |
517 |
|
|
518 |
// if nothing was done during this iteration (eg no streambuffer |
// if nothing was done during this iteration (eg no streambuffer |