/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Software synthesizer main audio mixer.
*
* @author Karl Helgason
*/
public final class SoftMainMixer {
// A private class thats contains a ModelChannelMixer and it's private buffers.
// This becomes necessary when we want to have separate delay buffers for each channel mixer.
private class SoftChannelMixerContainer
{
}
boolean active_sensing_on = false;
private boolean pusher_silent = false;
boolean readfully = true;
double[] balance = co_master_balance;
double[] volume = co_master_volume;
double[] coarse_tuning = co_master_coarse_tuning;
double[] fine_tuning = co_master_fine_tuning;
return null;
return balance;
return volume;
return coarse_tuning;
return fine_tuning;
return null;
}
};
synchronized (synth.control_mutex) {
activity();
// Universal Non-Real-Time SysEx
int subid2;
switch (subid1) {
case 0x08: // MIDI Tuning Standard
switch (subid2) {
case 0x01: // BULK TUNING DUMP
{
break;
}
case 0x04: // KEY-BASED TUNING DUMP
case 0x07: // SINGLE NOTE TUNING CHANGE (NON REAL-TIME)
// (BANK)
{
break;
}
// Real-Time)
// Real-Time)
{
break;
}
default:
break;
}
break;
case 0x09: // General Midi Message
switch (subid2) {
case 0x01: // General Midi 1 On
reset();
break;
case 0x02: // General Midi Off
reset();
break;
case 0x03: // General MidI Level 2 On
reset();
break;
default:
break;
}
break;
case 0x0A: // DLS Message
switch (subid2) {
case 0x01: // DLS On
reset();
break;
case 0x02: // DLS Off
reset();
break;
case 0x03: // DLS Static Voice Allocation Off
break;
case 0x04: // DLS Static Voice Allocation On
break;
default:
break;
}
break;
default:
break;
}
}
}
// Universal Real-Time SysEx
int subid2;
switch (subid1) {
case 0x04: // Device Control
switch (subid2) {
case 0x01: // Master Volume
case 0x02: // Master Balane
case 0x03: // Master fine tuning
case 0x04: // Master coarse tuning
if (subid2 == 0x01)
else if (subid2 == 0x02)
else if (subid2 == 0x03)
else if (subid2 == 0x04)
break;
case 0x05: // Global Parameter Control
int ix = 5;
int[] slotPath = new int[slotPathLen];
for (int i = 0; i < slotPathLen; i++) {
}
/ (paramWidth + valueWidth);
long[] params = new long[paramCount];
long[] values = new long[paramCount];
for (int i = 0; i < paramCount; i++) {
values[i] = 0;
for (int j = 0; j < paramWidth; j++)
for (int j = 0; j < valueWidth; j++)
}
break;
default:
break;
}
break;
case 0x08: // MIDI Tuning Standard
switch (subid2) {
case 0x02: // SINGLE NOTE TUNING CHANGE (REAL-TIME)
{
break;
}
case 0x07: // SINGLE NOTE TUNING CHANGE (REAL-TIME)
// (BANK)
{
break;
}
//(Real-Time)
// (Real-Time)
{
break;
}
default:
break;
}
break;
case 0x09: // Control Destination Settings
switch (subid2) {
case 0x01: // Channel Pressure
{
int ix = 0;
ix++;
}
break;
}
case 0x02: // Poly Pressure
{
int ix = 0;
ix++;
}
break;
}
case 0x03: // Control Change
{
int ix = 0;
ix++;
}
break;
}
default:
break;
}
break;
case 0x0A: // Key Based Instrument Control
{
switch (subid2) {
case 0x01: // Basic Message
}
break;
default:
break;
}
break;
}
default:
break;
}
}
}
}
}
return;
if(delay_midievent < 0)
delay_midievent = 0;
}
delay_midievent = 0;
}
void processAudioBuffers() {
{
}
if(i != CHANNEL_DELAY_LEFT &&
i != CHANNEL_DELAY_RIGHT &&
i != CHANNEL_DELAY_MONO &&
i != CHANNEL_DELAY_EFFECT1 &&
i != CHANNEL_DELAY_EFFECT2)
}
{
}
{
}
{
}
{
}
{
}
double volume_left;
double volume_right;
// perform control logic
synchronized (control_mutex) {
if (active_sensing_on) {
// Active Sensing
// if no message occurs for max 1000 ms
// then do AllSoundOff on all channels
active_sensing_on = false;
c.allSoundOff();
}
}
if (voicestatus[i].active)
sample_pos += buffer_len;
if (balance > 0.5)
else
if (cur_registeredMixers == null) {
if (registeredMixers != null) {
}
}
if (act_registeredMixers != null)
}
if (act_registeredMixers != null) {
// Make backup of left,right,mono channels
float[][] cbuffer = new float[nrofchannels][];
float[][] obuffer = new float[nrofchannels][];
if (nrofchannels != 1)
// Reroute default left,right output
{
}
{
}
{
}
if (nrofchannels != 1)
boolean hasactivevoices = false;
if (voicestatus[i].active)
hasactivevoices = true;
}
{
if (nrofchannels != 1) {
for (int i = 0; i < bufferlen; i++) {
float v = mono[i];
left[i] += v;
right[i] += v;
}
}
else
{
for (int i = 0; i < bufferlen; i++) {
}
}
}
synchronized (control_mutex) {
}
}
for (int j = 0; j < bufferlen; j++)
}
if (!hasactivevoices) {
synchronized (control_mutex) {
if (stoppedMixers != null) {
}
}
}
}
}
}
if (voicestatus[i].active)
{
if (nrofchannels != 1) {
for (int i = 0; i < bufferlen; i++) {
float v = mono[i];
left[i] += v;
right[i] += v;
}
}
else
{
for (int i = 0; i < bufferlen; i++) {
}
}
}
// Run effects
if (nrofchannels == 1)
// Set Volume / Balance
float amp;
float amp_delta;
for (int i = 0; i < bufferlen; i++) {
}
if (nrofchannels != 1) {
for (int i = 0; i < bufferlen; i++) {
right[i] *= volume_right;
}
}
} else {
float amp;
for (int i = 0; i < bufferlen; i++)
if (nrofchannels != 1) {
for (int i = 0; i < bufferlen; i++)
}
}
}
{
int midimessages_size;
synchronized (control_mutex) {
}
if(midimessages_size == 0)
{
if(pusher_silent_count > 5)
{
pusher_silent_count = 0;
synchronized (control_mutex) {
pusher_silent = true;
}
}
}
}
else
pusher_silent_count = 0;
agc.processAudio();
}
// Must only we called within control_mutex synchronization
public void activity()
{
long silent_samples = 0;
if(pusher_silent)
{
pusher_silent = false;
{
}
}
* (1000000.0 / samplerate));
}
if (stoppedMixers == null)
}
if (registeredMixers == null)
mixercontainer.buffers[i] =
}
}
sample_pos = 0;
/ synth.getControlRate());
}
reverb = new SoftReverb();
chorus = new SoftChorus();
agc = new SoftLimiter();
reverb.setMixMode(true);
chorus.setMixMode(true);
agc.setMixMode(false);
if (nrofchannels != 1)
if (nrofchannels != 1)
if (nrofchannels != 1)
if (nrofchannels != 1)
private final int nrofchannels
private final byte[] bbuffer = new byte[buffersize
.getSampleSizeInBits() / 8)
* nrofchannels];
private int bbuffer_pos = 0;
private final byte[] single = new byte[1];
public void fillBuffer() {
/*
boolean pusher_silent2;
synchronized (control_mutex) {
pusher_silent2 = pusher_silent;
}
if(!pusher_silent2)*/
for (int i = 0; i < nrofchannels; i++)
bbuffer_pos = 0;
}
if (available() == 0)
fillBuffer();
else {
int bbuffer_pos = this.bbuffer_pos;
this.bbuffer_pos = bbuffer_pos;
if (!readfully)
}
}
return len;
}
public int read() throws IOException {
if (ret == -1)
return -1;
}
public int available() {
}
public void close() {
}
};
}
return ais;
}
public void reset() {
channels[i].allSoundOff();
channels[i].resetAllControllers(true);
if (i == 9)
else
} else
}
// Reset Reverb
new int[]{0x01 * 128 + 0x01}, new long[]{0}, new long[]{4});
// Reset Chorus
new int[]{0x01 * 128 + 0x02}, new long[]{0}, new long[]{2});
}
synchronized (control_mutex) {
}
}
synchronized (control_mutex) {
}
}
synchronized (control_mutex) {
}
}
synchronized (control_mutex) {
}
}
public int getVolume() {
synchronized (control_mutex) {
}
}
public int getBalance() {
synchronized (control_mutex) {
}
}
public int getFineTuning() {
synchronized (control_mutex) {
}
}
public int getCoarseTuning() {
synchronized (control_mutex) {
}
}
long[] paramsvalue) {
return;
synchronized (control_mutex) {
// slothpath: 01xx are reserved only for GM2
paramsvalue[i]);
}
}
paramsvalue[i]);
}
}
}
}
if (object instanceof byte[])
processMessage((byte[]) object);
if (object instanceof MidiMessage)
}
if (message instanceof ShortMessage) {
return;
}
}
int status = 0;
if (status == 0xF0) {
return;
}
int data1;
int data2;
else
data1 = 0;
else
data2 = 0;
}
synchronized (synth.control_mutex) {
activity();
}
if (cmd == 0xF0) {
switch (status) {
case ShortMessage.ACTIVE_SENSING:
synchronized (synth.control_mutex) {
active_sensing_on = true;
}
break;
default:
break;
}
return;
}
return;
switch (cmd) {
case ShortMessage.NOTE_ON:
if(delay_midievent != 0)
else
break;
case ShortMessage.NOTE_OFF:
break;
case ShortMessage.POLY_PRESSURE:
break;
case ShortMessage.CONTROL_CHANGE:
break;
case ShortMessage.PROGRAM_CHANGE:
break;
case ShortMessage.CHANNEL_PRESSURE:
break;
case ShortMessage.PITCH_BEND:
break;
default:
break;
}
}
public long getMicrosecondPosition() {
if(pusher_silent)
{
{
* (1000000.0 / samplerate));
}
}
}
public void close() {
}
}