Beispiel #1
0
TPresError
TTargetView::Initialize(            ParamList   *inParamList,
                            const   TGUIRect    &inRect )
{
    {
        Param   *targetFontPtr;
        PARAM_GET_PTR_SUFFIX( inParamList, PRTargetFont, targetCode, targetFontPtr );
        TPresError  err = TTextProperties::SetTextProperties( targetFontPtr );
        if( err != presNoError )
        {
            gPresErrors.AddError( err, PARAM_NAME_SUFFIX( PRTargetFont, targetCode ) );
            return err;
        }
    }

    if( targetCode == 0 )
    {
        viewRect = inRect;
        TGUIView::Resized();
        PARAM_GET_NUM_SUFFIX( inParamList, PRVisResultMode, targetCode, visResultMode );
        PARAM_GET_NUM_SUFFIX( inParamList, PRVisTaskMode, targetCode, visTaskMode );
    }
    else
    {
        float   xLower,
                xUpper,
                yLower,
                yUpper;
        {
          int     xChannel,
                  yChannel;

          PARAM_GET_NUM_BY_INDEX( inParamList, PRFBCoordChannels, 0, xChannel );
          PARAM_GET_NUM_BY_INDEX( inParamList, PRFBCoordChannels, 1, yChannel );

          if( xChannel >= 0 )
          {
            PARAM_GET_NUM_SUFFIX_BY_INDEX( inParamList, FBCh__RS__L, xChannel, targetCode - 1, xLower );
            PARAM_GET_NUM_SUFFIX_BY_INDEX( inParamList, FBCh__RS__U, xChannel, targetCode - 1, xUpper );
          }
          else
          {
            xLower = -100.0;
            xUpper = 100.0;
          }
          
          if( yChannel >= 0 )
          {
            PARAM_GET_NUM_SUFFIX_BY_INDEX( inParamList, FBCh__RS__L, yChannel, targetCode - 1, yLower );
            PARAM_GET_NUM_SUFFIX_BY_INDEX( inParamList, FBCh__RS__U, yChannel, targetCode - 1, yUpper );
          }
          else
          {
            yLower = -100.0;
            yUpper = 100.0;
          }

          xLower = MIN( xLower, 100.0 );
          xLower = MAX( xLower, -100.0 );
          xUpper = MIN( xUpper, 100.0 );
          xUpper = MAX( xUpper, -100.0 );
          yLower = MIN( yLower, 100.0 );
          yLower = MAX( yLower, -100.0 );
          yUpper = MIN( yUpper, 100.0 );
          yUpper = MAX( yUpper, -100.0 );

          xLower = MIN( xLower, xUpper );
          yLower = MIN( yLower, yUpper );
        }

        float   inRectWidth = inRect.right - inRect.left,
                inRectHeight = inRect.bottom - inRect.top;
        viewRect.left = inRect.left + ( xLower + 100.0 ) / 200.0 * inRectWidth;
        viewRect.right = inRect.left + ( xUpper + 100.0 ) / 200.0 * inRectWidth;
        viewRect.top = inRect.top + ( yLower + 100.0 ) / 200.0 * inRectHeight;
        viewRect.bottom = inRect.top + ( yUpper + 100.0 ) / 200.0 * inRectHeight;
        TGUIView::Resized();

        if( xLower < xUpper && yLower < yUpper )
        {
            PARAM_GET_NUM_SUFFIX( inParamList, PRVisTaskMode, targetCode, visTaskMode );
            PARAM_GET_NUM_SUFFIX( inParamList, PRVisResultMode, targetCode, visResultMode );
        }
    }
    PARAM_GET_NUM_SUFFIX( inParamList, PRAudTaskMode, targetCode, audTaskMode );
    PARAM_GET_NUM_SUFFIX( inParamList, PRAudResultMode, targetCode, audResultMode );

    switch( audTaskMode )
    {
        case 0: // no auditory task
            break;
        case 1: // MIDI
            PARAM_ENABLE_SUFFIX( inParamList, PRGMTaskInstrument, targetCode );
            PARAM_ENABLE_SUFFIX( inParamList, PRGMTaskVolume, targetCode );
            PARAM_ENABLE_SUFFIX( inParamList, PRGMTaskNote, targetCode );
            {
                int gmInstrument,
                    gmVolume,
                    gmNote;
                PARAM_GET_NUM_SUFFIX( inParamList, PRGMTaskInstrument, targetCode, gmInstrument );
                PARAM_GET_NUM_SUFFIX( inParamList, PRGMTaskVolume, targetCode, gmVolume );
                PARAM_GET_NUM_SUFFIX( inParamList, PRGMTaskNote, targetCode, gmNote );
                taskMidiPlayer = new MidiPlayer( gmInstrument, gmVolume, gmNote );
            }
            break;
        case 2: // WAV
            {
                const char  *taskSound;
                Util::TPath curPath;
                PARAM_ENABLE_SUFFIX( inParamList, PRTaskSound, targetCode );
                PARAM_GET_STRING_SUFFIX( inParamList, PRTaskSound, targetCode, taskSound );
                taskWavePlayer = new WavePlayer;
                if( taskWavePlayer->SetFile( ( curPath + taskSound ).c_str() ).ErrorState()
                      != WavePlayer::noError )
                        return presFileOpeningError;
            }
            break;
        default:
            assert( false );
    }

    PARAM_GET_NUM( inParamList, PRContinuousAudResult, continuousAudResult );

    switch( audResultMode )
    {
        case 0: // no auditory result
            break;
        case 1: // MIDI
            PARAM_ENABLE_SUFFIX( inParamList, PRGMResultInstrument, targetCode );
            PARAM_ENABLE_SUFFIX( inParamList, PRGMResultVolume, targetCode );
            PARAM_ENABLE_SUFFIX( inParamList, PRGMResultNote, targetCode );
            {
                int gmInstrument,
                    gmVolume,
                    gmNote;
                PARAM_GET_NUM_SUFFIX( inParamList, PRGMResultInstrument, targetCode, gmInstrument );
                PARAM_GET_NUM_SUFFIX( inParamList, PRGMResultVolume, targetCode, gmVolume );
                PARAM_GET_NUM_SUFFIX( inParamList, PRGMResultNote, targetCode, gmNote );
                resultMidiPlayer = new MidiPlayer( gmInstrument, gmVolume, gmNote );
            }
            break;
        case 2: // WAV
            {
                const char  *resultSound;
                Util::TPath curPath;
                PARAM_ENABLE_SUFFIX( inParamList, PRResultSound, targetCode );
                PARAM_GET_STRING_SUFFIX( inParamList, PRResultSound, targetCode, resultSound );
                if( continuousAudResult )
                {
                    std::string contResultSound = "C";
                    contResultSound += resultSound;
                    contResultWavePlayer = new WavePlayer;
                    if( contResultWavePlayer->SetFile( ( curPath + contResultSound ).c_str() ).ErrorState()
                         != WavePlayer::noError )
                           return presFileOpeningError;
                }
                resultWavePlayer = new WavePlayer;
                if( resultWavePlayer->SetFile( ( curPath + resultSound ).c_str() ).ErrorState()
                     != WavePlayer::noError )
                       return presFileOpeningError;
            }
            break;
        default:
            assert( false );
    }

    visGoal = ( visTaskMode == 1 || visResultMode == 1 );
    if( visGoal )
    {
        TPresError err = TGUITargetView::InitGoal();
        if( err != presNoError )
            return err;
    }


    return presNoError;
}
TPresError
TFeedbackView::Initialize( ParamList *inParamList, const TGUIRect &inRect )
{
    viewRect = inRect;
    TGUIView::Resized();

    PARAM_GET_NUM_BY_INDEX( inParamList, PRFBCoordChannels, 0, xChannel );
    PARAM_GET_NUM_BY_INDEX( inParamList, PRFBCoordChannels, 1, yChannel );
    PARAM_GET_NUM( inParamList, PRFBBrightnessChannel, bChannel );

    PARAM_GET_NUM( inParamList, PRVisFBMode, visFBMode );

    TPresError  err;
    const char* fbCursorImg = NULL;
    switch( visFBMode )
    {
        case 0: // none
            break;
        case 1: // cursor from file
            PARAM_ENABLE( inParamList, PRFBCursorImg );
            PARAM_GET_STRING( inParamList, PRFBCursorImg, fbCursorImg );
            // fallthrough
        case 2: // ball cursor
            err = TGUIFeedbackView::InitCursor( fbCursorImg );
            if( err != presNoError )
                return err;
            break;
#ifdef PERUVIAN_BRIGHTNESS_HACK
        case 3: // brightness
            err = TGUIFeedbackView::InitCursor( PERUVIAN_CURSOR );
            if( err != presNoError )
                return err;
            break;
#endif // PERUVIAN_BRIGHTNESS_HACK
        default:
            assert( false );
    }

    PARAM_GET_NUM( inParamList, PRAudFBMode, audFBMode );

    switch( audFBMode )
    {
        case 0: // none
            break;
        case 1: // MIDI
            {
                int gmFBScale,
                    gmFBInstrument,
                    gmFBVolume;

                PARAM_ENABLE( inParamList, PRGMFBInterval );
                PARAM_ENABLE( inParamList, PRGMFBScale );
                PARAM_ENABLE( inParamList, PRGMFBInstrument );
                PARAM_ENABLE( inParamList, PRGMFBVolume );
                PARAM_ENABLE( inParamList, PRGMFBCenterNote );

                PARAM_GET_NUM( inParamList, PRGMFBInterval, gmFBInterval );
                PARAM_GET_NUM( inParamList, PRGMFBScale, gmFBScale );

                switch( gmFBScale )
                {
                    case 0: // null scale
                        upScale = downScale = nullScale;
                        scaleLength = nullScaleLength;
                        break;
                    case 1: // chromatic
                        upScale = downScale = chromaticScale;
                        scaleLength = chromaticScaleLength;
                        break;
                    case 2: // major
                        upScale = downScale = majorScale;
                        scaleLength = majorScaleLength;
                        break;
                    case 3: // melodic minor
                        upScale = melodicMinorUpScale;
                        downScale = melodicMinorDownScale;
                        scaleLength = minorScaleLength;
                        break;
                    case 4: // harmonic minor
                        upScale = downScale = harmonicMinorScale;
                        scaleLength = minorScaleLength;
                        break;
                    case 5: // pentatonic
                        upScale = downScale = pentatonicScale;
                        scaleLength = pentatonicScaleLength;
                        break;
                    case 6: // diatonic
                        upScale = downScale = diatonicScale;
                        scaleLength = diatonicScaleLength;
                        break;
                    default:
                        return presParamOutOfRangeError;
                }

                PARAM_GET_NUM( inParamList, PRGMFBInstrument, gmFBInstrument );
                PARAM_GET_NUM( inParamList, PRGMFBVolume, gmFBVolume );
                PARAM_GET_NUM( inParamList, PRGMFBCenterNote, gmFBCenterNote );

                midiPlayer = new MidiPlayer( gmFBInstrument, gmFBVolume );
            }
            break;
#ifdef USE_WAVE_SYNTH
        case 2: // continuous synth
            {
                int gmFBVolume;

                PARAM_ENABLE( inParamList, PRGMFBInterval );
                PARAM_ENABLE( inParamList, PRGMFBVolume );
                PARAM_ENABLE( inParamList, PRGMFBCenterNote );
                PARAM_GET_NUM( inParamList, PRGMFBInterval, gmFBInterval );
                PARAM_GET_NUM( inParamList, PRGMFBVolume, gmFBVolume );
                PARAM_GET_NUM( inParamList, PRGMFBCenterNote, gmFBCenterNote );

                waveSynth = new TWaveSynth;
                waveSynth->SetVolume( gmFBVolume / 128.0 );
                float samplingRate,
                      sampleBlockSize;
                PARAM_GET_NUM( inParamList, SamplingRate, samplingRate );
                PARAM_GET_NUM( inParamList, SampleBlockSize, sampleBlockSize );
                waveSynth->SetTimeConstant( 10 * sampleBlockSize / samplingRate );
            }
            break;
#endif // USE_WAVE_SYNTH
        default:
            assert( false );
    }

    PARAM_GET_NUM( inParamList, PRFBAlwaysOn, fbAlwaysOn );
    return presNoError;
}