Ejemplo n.º 1
0
OSStatus MT32Synth::RestoreState(CFPropertyListRef inData) {
    MusicDeviceBase::RestoreState(inData);
    synth->setOutputGain(Globals()->GetParameter(kGlobalVolumeParam));
    synth->setReverbOutputGain(Globals()->GetParameter(kReverbGainParam));
    synth->setReverbEnabled(Globals()->GetParameter(kReverbEnabledParam) == 1.0);
    sendMIDI(0xC1, Globals()->GetParameter(kInstrumentParam), 0x00, 0x00);
    return noErr;
}
Ejemplo n.º 2
0
OSStatus MT32Synth::Initialize() {
    
    destFormat = GetStreamFormat(kAudioUnitScope_Output, 0);
    
    AudioStreamBasicDescription sourceDescription;
    sourceDescription.mSampleRate = 32000;
    sourceDescription.mBytesPerFrame = 4;
    sourceDescription.mBitsPerChannel = 16;
    sourceDescription.mFormatID = kAudioFormatLinearPCM;
    sourceDescription.mBytesPerPacket = 4;
    sourceDescription.mChannelsPerFrame = 2;
    sourceDescription.mFormatFlags = kAudioFormatFlagIsSignedInteger;
    sourceDescription.mFramesPerPacket = 1;
    sourceDescription.mReserved = 0;
    
    AudioConverterNew(&sourceDescription, &destFormat, &audioConverterRef);
    MT32Emu::FileStream controlROMFile;
    MT32Emu::FileStream pcmROMFile;
    
    if(!controlROMFile.open("/Library/MT32/MT32_CONTROL.ROM")) {
        printf("Error opening MT32_CONTROL.ROM\n");
    }
    
    if(!pcmROMFile.open("/Library/MT32/MT32_PCM.ROM")) {
        printf("Error opening MT32_PCM.ROM\n");
    }
    
    romImage = MT32Emu::ROMImage::makeROMImage(&controlROMFile);
    pcmRomImage = MT32Emu::ROMImage::makeROMImage(&pcmROMFile);
    
    synth = new MT32Emu::Synth();
    synth->open(*romImage, *pcmRomImage);
    
    MT32Emu::ROMImage::freeROMImage(romImage);
    MT32Emu::ROMImage::freeROMImage(pcmRomImage);
    
    sendMIDI(0xC1, 0x00, 0x00, 0x00);
    MusicDeviceBase::Initialize();
    
    synth->setOutputGain(2.0);
    
    return noErr;
}
Ejemplo n.º 3
0
OSStatus MT32Synth::SetParameter(AudioUnitParameterID inID, AudioUnitScope 	inScope, AudioUnitElement inElement, AudioUnitParameterValue	inValue, UInt32	inBufferOffsetInFrames) {
    
    if(inID == kGlobalVolumeParam) {
        if(synth){
            synth->setOutputGain(inValue);
        }
    } else  if(inID == kInstrumentParam) {
        sendMIDI(0xC1, inValue, 0x00, 0x00);
    } else if(inID == kReverbEnabledParam) {
        if(synth){
            synth->setReverbEnabled(inValue == 1.0);
        }
    } else if(inID == kReverbGainParam) {
        if(synth){
            synth->setReverbOutputGain(inValue);
        }
    }
    return MusicDeviceBase::SetParameter(inID, inScope, inElement, inValue, inBufferOffsetInFrames);
}
Ejemplo n.º 4
0
void Switch::update(){   
    int value = ofClamp(midiValue, getMin(), getMax());
    bool send = false; 
    if(value < threshold){ //change from 0 to 1
        if(currentArea == 1){
            send = true; 
        }  
        currentArea = 0;              
    }
    else if(value >= threshold){ //change from 1 to 0
        if(currentArea == 0){
            send = true;
        }
        currentArea = 1;        
    }
    if(sendMIDIonUpdate){
        sendMIDI();
    }
}
Ejemplo n.º 5
0
Archivo: Pot.cpp Proyecto: imclab/Lines
void Pot::update(){     
    currentValue = ofClamp(currentValue, outputMin, outputMax);   
    midiValue = ofMap(currentValue, getMin(), getMax(), outputMin, outputMax);
    midiValue = ofClamp(midiValue, outputMin, outputMax);
        
    //normalValue = ofClamp(currentValue, outputMin, outputMax);      
    //cout << borderAreaWidth << endl;
    /*
    switch(mode){   
        case NORMAL:
            midiValue = normalValue;
            break;
        case SWITCH_OFF_BOTTOM://under threshold, sends zero. after threshold, (outputMin, outputMax)              
            if(currentValue < zeroThreshold){                 
                midiValue = 0;                
            }
            else{
                midiValue = normalValue; //or from zerothreshold??
            }            
            break;
        case MIN_MAX_AREAS: //under and over thresholds, sends min and max respectively.             
            if(currentValue < bottomAreaPos){
                midiValue = outputMin;
            }
            else if(currentValue > topAreaPos){
                midiValue = outputMax;
            }
            else{
                midiValue = normalValue;
            } 
            break;          
    }*/ 
    
    if(sendMIDIonUpdate){
        sendMIDI();
    }
}
Ejemplo n.º 6
0
OSStatus MT32Synth::HandleNoteOff(	UInt8 inChannel, UInt8 inNoteNumber, UInt8 inVelocity, UInt32 inStartFrame) {
    sendMIDI(0x81, inNoteNumber, inVelocity, 0x00);
    return MusicDeviceBase::HandleNoteOff(inChannel, inNoteNumber, inVelocity, inStartFrame);
}
Ejemplo n.º 7
0
OSStatus MT32Synth::HandlePitchWheel(UInt8 inChannel, UInt8 inPitch1, UInt8 inPitch2, UInt32 inStartFrame) {
    sendMIDI(0xE1, inPitch1, inPitch2, inStartFrame);
    return MusicDeviceBase::HandlePitchWheel(inChannel, inPitch1, inPitch2, inStartFrame);
}