Exemplo n.º 1
0
Track::~Track ( )
{
    Loggable::block_start();

    /* must destroy sequences first to preserve proper log order */
    takes->clear();
    control->clear();
    annotation->clear();
    delete sequence();

    takes = NULL;
    control = NULL;
    annotation = NULL;

    log_destroy();

    /* ensure that soloing accounting is performed */
    solo( false );

    timeline->remove_track( this );

    /* give up our ports */
    configure_inputs( 0 );
    configure_outputs( 0 );

    _sequence = NULL;

    if ( _name )
        free( _name );

    Loggable::block_end();
}
Exemplo n.º 2
0
/** build the context menu */
Fl_Menu_Button &
Track::menu ( void ) const
{

    int c = output.size();
    int s = size();

    _menu.clear();

    _menu.add( "Takes/Show all takes", 0, 0, 0, FL_MENU_TOGGLE | ( show_all_takes() ? FL_MENU_VALUE : 0 ) );
    _menu.add( "Takes/New", 0, 0, 0 );

    if ( takes->children() )
    {
        _menu.add( "Takes/Remove", 0, 0, 0 );
        _menu.add( "Takes/Remove others", 0, 0, 0, FL_MENU_DIVIDER );
        
        for ( int i = 0; i < takes->children(); ++i )
        {
            Sequence *s = (Sequence *)takes->child( i );
            
            char n[256];
            snprintf( n, sizeof(n), "Takes/%s", s->name() );

            _menu.add( n, 0, 0, s);
        }
    }

    _menu.add( "Type/Mono",  0, 0, 0, FL_MENU_RADIO | ( c == 1 ? FL_MENU_VALUE : 0 ) );
    _menu.add( "Type/Stereo", 0, 0, 0, FL_MENU_RADIO | ( c == 2 ? FL_MENU_VALUE : 0 ));
    _menu.add( "Type/Quad",            0, 0, 0, FL_MENU_RADIO | ( c == 4 ? FL_MENU_VALUE : 0 ) );
    _menu.add( "Type/...",             0, 0, 0, FL_MENU_RADIO | ( c == 3 || c > 4 ? FL_MENU_VALUE : 0 ) );
    _menu.add( "Overlay controls",   0, 0, 0, FL_MENU_TOGGLE | ( overlay_controls() ? FL_MENU_VALUE : 0 ) );
    _menu.add( "Add Control",     0, 0, 0 );
    _menu.add( "Add Annotation",  0, 0, 0 );
    _menu.add( "Color",           0, 0, 0 );
    _menu.add( "Rename",          FL_CTRL + 'n', 0, 0 );
    _menu.add( "Size/Small",           FL_ALT + '1', 0, 0, FL_MENU_RADIO | ( s == 0 ? FL_MENU_VALUE : 0 ) );
    _menu.add( "Size/Medium",          FL_ALT + '2', 0, 0, FL_MENU_RADIO | ( s == 1 ? FL_MENU_VALUE : 0 ) );
    _menu.add( "Size/Large",           FL_ALT + '3', 0, 0, FL_MENU_RADIO | ( s == 2 ? FL_MENU_VALUE : 0 ) );
    _menu.add( "Size/Huge",           FL_ALT + '4', 0, 0, FL_MENU_RADIO | ( s == 3 ? FL_MENU_VALUE : 0 ) );
    _menu.add( "Flags/Record",         FL_CTRL + 'r', 0, 0, FL_MENU_TOGGLE | ( armed() ? FL_MENU_VALUE : 0 ) );
    _menu.add( "Flags/Mute",            FL_CTRL + 'm', 0, 0, FL_MENU_TOGGLE | ( mute() ? FL_MENU_VALUE : 0 ) );
    _menu.add( "Flags/Solo",           FL_CTRL + 's', 0, 0, FL_MENU_TOGGLE | ( solo() ? FL_MENU_VALUE : 0 ) );
    _menu.add( "Move Up",        FL_SHIFT + '1', 0, 0 );
    _menu.add( "Move Down",        FL_SHIFT + '2', 0, 0 );
    _menu.add( "Remove",          0, 0, 0 ); // transport->rolling ? FL_MENU_INACTIVE : 0 );
  
    _menu.callback( &Track::menu_cb, (void*)this );

    return _menu;
}
Exemplo n.º 3
0
void
Track::get_unjournaled ( Log_Entry &e ) const
{
    e.add( ":height",          size()           );
    e.add( ":inputs",          input.size()     );
    e.add( ":outputs",         output.size()    );
    e.add( ":show-all-takes",  show_all_takes()  );
    e.add( ":overlay-controls", overlay_controls()  );    
    e.add( ":armed",           armed()          );
    e.add( ":mute",            mute()           );
    e.add( ":solo",            solo()           );
    e.add( ":row",             timeline->find_track( this ) );
}
Exemplo n.º 4
0
Arquivo: main.cpp Projeto: Saarg/ISN
int main()
{
    // Create the main window
    sf::RenderWindow window(sf::VideoMode(800, 900), "SFML window");   //creation d'une fenetre de 800/900
    window.setFramerateLimit(60);                                      //limite le programme a 60 fps

    mapping backgroung;

    sf::Font font;
    if (!font.loadFromFile("foughtknight.ttf"))                        //police d'écriture
        return EXIT_FAILURE;

    sf::Text texttitle("SpaceShoot", font, 50);

    sf::Text text[5];
    text[0]=sf::Text("solo", font, 50 );
    text[1]=sf::Text("duel", font, 50 );
    text[2]=sf::Text("multijoueur", font, 50 );
    text[3]=sf::Text("options", font, 50 );
    text[4]=sf::Text("quitter", font, 50 );                            //tableau de caractere

    int a(0);                                                          //a ---> la variable permettant de naviguer dans le menu

    texttitle.setPosition(window.getSize().x/2-(texttitle.getGlobalBounds().width)/2, 100);

    text[0].setPosition(window.getSize().x/2-(text[0].getGlobalBounds().width)/2, 250);
    text[1].setPosition(window.getSize().x/2-(text[1].getGlobalBounds().width)/2, 300);
    text[2].setPosition(window.getSize().x/2-(text[2].getGlobalBounds().width)/2, 350);
    text[3].setPosition(window.getSize().x/2-(text[3].getGlobalBounds().width)/2, 400);
    text[4].setPosition(window.getSize().x/2-(text[4].getGlobalBounds().width)/2, 450); //position des textes

    float x=10, y=50;
    float A=(-4*y)/(x*x), B=-(-4*y)/x;
    sf::VertexArray propul(sf::Points, x*y);
    for(int i = 0 ; i < y ; i++)
    {
        for(int j = 0 ; j < x ; j++)
        {
            float YMAX=A*(j*j)+B*j;

            int alpha = 255-(i/YMAX)*255;
            if(alpha<0)
                alpha = 0;

            int R = 255;
            int G = 100;
            int B = 70;

            propul[i*x+j].position = sf::Vector2f(j, y-i);
            propul[i*x+j].color = sf::Color(R, G, B, alpha);
        }
    }

    // Start the game loop
    while (window.isOpen())
    {
        // Process events
        sf::Event event;
        text[a].setColor(sf::Color::White);
        while (window.pollEvent(event))
        {
            // Close window : exit
            if (event.type == sf::Event::Closed)
                window.close();
            else if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Up))//touche Z ou haut
                a=a-1;
            else if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Down))
                a=a+1;
        }
        if(a<0 )//condition
            a =4;
        else if(a>4.4 )
            a =0;
        text[a].setColor(sf::Color::Red);

        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Return))//sionfaitentré
        {
            switch(a)
            {
            case 0:
                solo(&window);
                break;

            case 1:
                break;

            case 2:
                multiplayer(&window);
                break;

            case 3:
                break;

            case 4:
                window.close();
                break;

            }
        }


        window.clear();
        backgroung.Draw(&window);
        window.draw(texttitle);

        for(int i=0; i<=4; i++)
            window.draw(text[i]);

        window.display();
    }
}
Exemplo n.º 5
0
void
Track::menu_cb ( const Fl_Menu_ *m )
{
    char picked[256];

    m->item_pathname( picked, sizeof( picked ) );

    DMESSAGE( "Picked: %s", picked );

    Logger log( this );

    if ( ! strcmp( picked, "Type/Mono" ) )
    {
        command_configure_channels( 1 );
    }
    else if ( ! strcmp( picked, "Type/Stereo" ) )
    {
        command_configure_channels( 2 );
    }
    else if ( ! strcmp( picked, "Type/Quad" ) )
    {
        command_configure_channels( 4 );
    }
    else if ( ! strcmp( picked, "Type/..." ) )
    {
        const char *s = fl_input( "How many channels?", "3" );
        if ( s )
        {

            int c = atoi( s );

            if ( c <= 0 || c > 10 )
                fl_alert( "Invalid number of channels." );
            else
            {
                command_configure_channels(c);
            }
        }
    }
    else if ( ! strcmp( picked, "/Add Control" ) )
    {
        /* add audio track */
        char *name = get_unique_control_name( "Control" );

        timeline->wrlock();
        new Control_Sequence( this, name );
        timeline->unlock();
    }
    else if ( ! strcmp( picked, "/Overlay controls" ) )
    {
        overlay_controls( ! m->mvalue()->value() );
    }
    else if ( ! strcmp( picked, "/Add Annotation" ) )
    {
        add( new Annotation_Sequence( this ) );
    }
    else if ( ! strcmp( picked, "/Color" ) )
    {
        unsigned char r, g, b;

        Fl::get_color( color(), r, g, b );

        if ( fl_color_chooser( "Track Color", r, g, b ) )
        {
            color( fl_rgb_color( r, g, b ) );
        }

        redraw();
    }
    else if ( ! strcmp( picked, "Flags/Record" ) )
    {
        armed( m->mvalue()->flags & FL_MENU_VALUE );
    }
    else if ( ! strcmp( picked, "Flags/Mute" ) )
    {
        mute( m->mvalue()->flags & FL_MENU_VALUE );
    }
    else if ( ! strcmp( picked, "Flags/Solo" ) )
    {
        solo( m->mvalue()->flags & FL_MENU_VALUE );
    }
    else if ( ! strcmp( picked, "Size/Small" ) )
    {
        size( 0 );
    }
    else if ( ! strcmp( picked, "Size/Medium" ) )
    {
        size( 1 );
    }
    else if ( ! strcmp( picked, "Size/Large" ) )
    {
        size( 2 );
    }
    else if ( ! strcmp( picked, "Size/Huge" ) )
    {
        size( 3 );
    }
    else if ( ! strcmp( picked, "/Remove" ) )
    {
        int r = fl_choice( "Are you certain you want to remove track \"%s\"?", "Cancel", NULL, "Remove", name() );

        if ( r == 2 )
        {
            timeline->command_remove_track( this );
             Fl::delete_widget( this );
        }
    }
    else if ( ! strcmp( picked, "/Rename" ) )
    {
        ((Fl_Sometimes_Input*)name_field)->take_focus();
    }
    else if ( ! strcmp( picked, "/Move Up" ) )
    {
        timeline->command_move_track_up( this );
    }
    else if ( ! strcmp( picked, "/Move Down" ) )
    {
        timeline->command_move_track_down( this );
    }
    else if ( !strcmp( picked, "Takes/Show all takes" ) )
    {
        show_all_takes( ! m->mvalue()->value() );
    }
    else if ( !strcmp( picked, "Takes/New" ) )
    {
        timeline->wrlock();
        sequence( (Audio_Sequence*)sequence()->clone_empty() );
        timeline->unlock();
    }
    else if ( !strcmp( picked, "Takes/Remove" ) )
    {
            if ( takes->children() )
            {
                Loggable::block_start();

                timeline->wrlock();

                Audio_Sequence *s = sequence();

                sequence( (Audio_Sequence*)takes->child( 0 ) );

                delete s;

                timeline->unlock();

                Loggable::block_end();
            }
    }
    else if ( !strcmp( picked, "Takes/Remove others" ))
    {
        if ( takes->children() )
            {
                Loggable::block_start();

                takes->clear();

                Loggable::block_end();
            }
    }
    else if ( !strncmp( picked, "Takes/", sizeof( "Takes/" ) - 1 ) )
    {
        Audio_Sequence* s = (Audio_Sequence*)m->mvalue()->user_data();

        timeline->wrlock();
        sequence( s );
        timeline->unlock();
    }
}
Exemplo n.º 6
0
void
Track::set ( Log_Entry &e )
{
    for ( int i = 0; i < e.size(); ++i )
    {
        const char *s, *v;

        e.get( i, &s, &v );

        if ( ! strcmp( s, ":height" ) )
        {
            size( atoi( v ) );
            adjust_size();
        }
        else if ( ! strcmp( s, ":selected" ) )
            _selected = atoi( v );
//                else if ( ! strcmp( s, ":armed"
        else if ( ! strcmp( s, ":name" ) )
            name( v );
        else if ( ! strcmp( s, ":inputs" ) )
            configure_inputs( atoi( v ) );
        else if ( ! strcmp( s, ":outputs" ) )
            configure_outputs( atoi( v ) );
        else if ( ! strcmp( s, ":color" ) )
        {
            color( (Fl_Color)atoll( v ) );
            redraw();
        }
        else if ( ! strcmp( s, ":show-all-takes" ) )
            show_all_takes( atoi( v ) );
        else if ( ! strcmp( s, ":overlay-controls" ) )
            overlay_controls( atoi( v ) );
        else if ( ! strcmp( s, ":solo" ) )
            solo( atoi( v ) );
        else if ( ! strcmp( s, ":mute" ) )
            mute( atoi( v ) );
        else if ( ! strcmp( s, ":arm" ) )
            armed( atoi( v ) );
        else if ( ! strcmp( s, ":sequence" ) )
        {
            int i;
            sscanf( v, "%X", &i );

            if ( i )
            {
                Audio_Sequence *t = (Audio_Sequence*)Loggable::find( i );

                /* FIXME: our track might not have been
                 * defined yet... what should we do about this
                 * chicken/egg problem? */
                if ( t )
                {
//                        assert( t );

                    sequence( t );
                }

            }

        }
        else if ( ! strcmp( s, ":row" ) )
            row( atoi( v ) );
    }
}
Exemplo n.º 7
0
void
TranzportClient::readData()
{
    memcpy(previousbuf, currentbuf, 8);
    ssize_t val;
    static timeT loop_start_time=0;
    static timeT loop_end_time=0;

    while ((val=read(m_descriptor,currentbuf,8)) == 8) {
        uint32_t new_buttons = current_buttons ^ previous_buttons;
        if (status == 0x1) {
            RG_DEBUG << "TranzportClient: device just came online";

            while (not commands.empty()) {
                commands.pop();
            }
            device_online = true;

            m_rgDocument = m_rgGUIApp->getDocument();
            m_composition = &m_rgGUIApp->getDocument()->getComposition();
            stateUpdate();
        }

        if (status == 0xff) {
            RG_DEBUG << "TranzportClient: device just went offline";

            device_online = false;
            return;
        }

        if (new_buttons & TrackSolo  and
            current_buttons & TrackSolo) {
            if (current_buttons & Shift) {
                bool soloflag = m_composition->isSolo();
                emit solo(not soloflag);
            }
        }

        if (new_buttons & Add  and
            current_buttons & Add) {
            if (current_buttons & Shift) {
            } else {
                AddMarkerCommand* cmd = new AddMarkerCommand(m_composition,
                                                             m_composition->getPosition(),
                                                             "tranzport",
                                                             "");
                CommandHistory::getInstance()->addCommand(cmd);
            }
        }

        if (new_buttons & Prev  and
            current_buttons & Prev) {
            RG_DEBUG << "TranzportClient:: received marker previous";

            if (current_buttons & Shift) {
            } else {
                timeT currentTime = m_composition->getPosition();
                Composition::markercontainer& mc = m_composition->getMarkers();
                timeT closestPrevious = -1;

                for (Composition::markerconstiterator it = mc.begin();
                     it != mc.end();
                     ++it) {
                    timeT markerTime = (*it)->getTime();
                    if (markerTime < currentTime  and
                        markerTime > closestPrevious) {
                        closestPrevious = markerTime;
                    }
                }

                if (closestPrevious >= 0) {
                    RG_DEBUG << "Tranzport:: setting position: " << closestPrevious;

                    emit setPosition(closestPrevious);
                }
            }
        }

        if (new_buttons & Next  and
            current_buttons & Next)
        {
            RG_DEBUG << "TranzportClient:: received marker next";

            if (current_buttons & Shift) {
            } else {
                timeT currentTime = m_composition->getPosition();
                Composition::markercontainer& mc = m_composition->getMarkers();
                timeT closestNext = std::numeric_limits<long>::max();
                
                for (Composition::markerconstiterator it = mc.begin();
                     it != mc.end();
                     ++it) {
                    timeT markerTime = (*it)->getTime();
                    if (markerTime > currentTime and
                        markerTime < closestNext) {
                        closestNext = markerTime;
                    }
                }

                if (closestNext < std::numeric_limits<long>::max()) {
                    RG_DEBUG << "Tranzport:: setting position: " << closestNext;

                    emit setPosition(closestNext);
                }
            }
        }

        if (new_buttons & Undo  and
            current_buttons & Undo) {
            if (current_buttons & Shift) {
                emit redo();
            } else {
                emit undo();
            }
        }

        if (new_buttons & Play  and
            current_buttons & Play) {
            if (current_buttons & Shift) {
            } else {
                emit play();
            }
        }

        if (new_buttons & Stop  and
            current_buttons & Stop) {
            if (current_buttons & Shift) {
            } else {
                emit stop();
            }
        }

        if (new_buttons & Record  and
            current_buttons & Record) {
            if (current_buttons & Shift) {
            } else {
                emit record();
            }
        }

        if (new_buttons & Loop  and
            current_buttons & Loop) {
            if (current_buttons & Shift) {
            } else {
                loop_start_time = m_composition->getPosition();
                loop_end_time = loop_start_time;
            }
        }

        if (new_buttons & Loop  and
            (not (current_buttons & Loop))) {
            if (current_buttons & Shift) {
            } else {
                if (loop_start_time == loop_end_time) {
                    m_rgDocument->setLoop(0,0);
                }

                loop_start_time = 0;
                loop_end_time = 0;
            }
        }

        if (new_buttons& Rewind  and
            current_buttons & Rewind) {
            if (current_buttons&Shift) {
                emit rewindToBeginning();
            } else {
                emit rewind();
            }
        }

        if (new_buttons & FastForward  and
            current_buttons & FastForward) {
            if (current_buttons & Shift) {
                emit fastForwardToEnd();
            } else {
                emit fastForward();
            }
        }

        if (new_buttons & TrackRec  and
            current_buttons & TrackRec) {
            if (current_buttons & Shift) {
            } else {
                emit trackRecord();
            }
        }

        if (new_buttons & TrackRight  and
            current_buttons & TrackRight) {
            if (current_buttons & Shift) {
            } else {
                emit trackDown();
            }
        }

        if (new_buttons & TrackLeft  and
            current_buttons & TrackLeft) {
            if (current_buttons& Shift) {
            } else {
                emit trackUp();
            }
        }

        if (new_buttons & TrackMute  and
            current_buttons & TrackMute) {
            if (current_buttons & Shift) {
            } else {
                emit trackMute();
            }
        }

        if (datawheel) {
            if (datawheel < 0x7F) {
                if (current_buttons & Loop) {
                    loop_end_time += datawheel *
                        m_composition->getDurationForMusicalTime(loop_end_time, 0,1,0,0);
                    m_rgDocument->setLoop(loop_start_time, loop_end_time);
                } else if(current_buttons & Shift) {
                    timeT here = m_composition->getPosition();
                    here += datawheel * m_composition->getDurationForMusicalTime(here,0,0,1,0);
                    if (here <= m_composition->getEndMarker()) {
                        emit setPosition(here);
                    }
                } else {
                    timeT here = m_composition->getPosition();
                    here += datawheel * m_composition->getDurationForMusicalTime(here,0,1,0,0);
                    if (here <= m_composition->getEndMarker()) {
                        emit setPosition(here);
                    }
                }
            } else {
#define DATAWHEEL_VALUE (1 + (0xFF - (datawheel)))
                if (current_buttons & Loop) {
                    loop_end_time -= (1 + (0xFF - datawheel)) *
                        m_rgGUIApp->getDocument()->getComposition().getDurationForMusicalTime(loop_end_time, 0,1,0,0);
                    m_rgDocument->setLoop(loop_start_time, loop_end_time);
                }

                if (current_buttons & Shift) {
                    timeT here = m_composition->getPosition();
                    here -= DATAWHEEL_VALUE *  m_composition->getDurationForMusicalTime(here,0,0,1,0);
                    if (here >= m_composition->getStartMarker()) {
                        emit setPosition(here);
                    }
                } else {
                    timeT here = m_composition->getPosition();
                    here -= DATAWHEEL_VALUE *  m_composition->getDurationForMusicalTime(here,0,1,0,0);
                    if (here >= m_composition->getStartMarker()) {
                        emit setPosition(here);
                    }
                }
#undef DATAWHEEL_VALUE
            }
        }

        memcpy(previousbuf, currentbuf, 8);
    }

    if (val == -1) {
        if (errno == EAGAIN) {
            return;
        } else {
            RG_DEBUG << "TranzportClient::readData: error " << strerror(errno);
        }
    } else {
        RG_DEBUG << "TranzportClient::readData: partial read of length " << val;
        RG_DEBUG << "TranzportClient::readData: this should not happen " << val;
    }
}