Example #1
0
    /**
     * @brief テキストストリームから読み込みを行い、初期化を行う
     * @param stream (TextStream) 読み込むテキストストリーム
     * @param lastLine (table) 読み込んだ最後の行。テーブルの ["value"] に文字列が格納される
     */
    explicit Mixer( TextStream &stream, std::string &lastLine ){
        this->masterFeder = 0;
        this->masterPanpot = 0;
        this->masterMute = 0;
        this->outputMode = 0;
        int tracks = 0;
        std::string buffer = "";
        lastLine = stream.readLine();
        while( lastLine.at( 0 ) != '[' ){
            std::vector<std::string> params = StringUtil::explode( "=", lastLine );
            if( params[0] == "MasterFeder" ){
                this->masterFeder = StringUtil::parseInt<int>( params[1] );
            }else if( params[0] == "MasterPanpot" ){
                this->masterPanpot = StringUtil::parseInt<int>( params[1] );
            }else if( params[0] == "MasterMute" ){
                this->masterMute = StringUtil::parseInt<int>( params[1] );
            }else if( params[0] == "OutputMode" ){
                this->outputMode = StringUtil::parseInt<int>( params[1] );
            }else if( params[0] == "Tracks" ){
                tracks = StringUtil::parseInt<int>( params[1] );
            }else{
                if( params[0].find( "Feder" ) == 0 ||
                    params[0].find( "Panpot" ) == 0 ||
                    params[0].find( "Mute" ) == 0  ||
                    params[0].find( "Solo" ) == 0 )
                {
                    buffer = buffer + params[0] + "=" + params[1] + "\n";
                }
            }
            if( !stream.ready() ){
                break;
            }
            lastLine = stream.readLine();
        }

        for( int i = 0; i < tracks; i++ ){
            this->slave.push_back( MixerItem( 0, 0, 0, 0 ) );
        }
        std::vector<std::string> spl = StringUtil::explode( "\n", buffer );
        for( int i = 0; i < spl.size(); i++ ){
            std::string ind = "";
            int index;
            std::vector<std::string> spl2 = StringUtil::explode( "=", spl[i] );
            if( spl2[0].find( "Feder" ) == 0 ){
                ind = spl2[0].substr( std::string( "Feder" ).size() );
                index = StringUtil::parseInt<int>( ind );
                this->slave[index].feder = StringUtil::parseInt<int>( spl2[1] );
            }else if( spl2[0].find( "Panpot" ) == 0 ){
                ind = spl2[0].substr( std::string( "Panpot" ).size() );
                index = StringUtil::parseInt<int>( ind );
                this->slave[index].panpot = StringUtil::parseInt<int>( spl2[1] );
            }else if( spl2[0].find( "Mute" ) == 0 ){
                ind = spl2[0].substr( std::string( "Mute" ).size() );
                index = StringUtil::parseInt<int>( ind );
                this->slave[index].mute = StringUtil::parseInt<int>( spl2[1] );
            }else if( spl2[0].find( "Solo" ) == 0 ){
                ind = spl2[0].substr( std::string( "Solo" ).size() );
                index = StringUtil::parseInt<int>( ind );
                this->slave[index].solo = StringUtil::parseInt<int>( spl2[1] );
            }
        }
    }