Exemple #1
0
// ----------------------------------------------------------------------------
//
void HttpRestServices::control_beatsampler_start( Venue* venue, DMXHttpSession* session, CString& response, LPCSTR data, DWORD size, LPCSTR content_type )
{
    SimpleJsonParser parser;

    session->getBeatDetector().removeAllFrequencyEvents();
    session->getBeats().clear();

    session->getBeatDetector().attach( venue->getAudio(), 64 );

    try {
        parser.parse( data );

        JsonNodePtrArray bins = parser.getObjects();

        for ( JsonNode* bin : bins ) {
            unsigned start_freq = bin->get<unsigned>( "start_freq" );
            unsigned end_freq = bin->get<unsigned>( "end_freq" );

            session->getBeats().emplace_back( start_freq, end_freq );
        }
    }
    catch ( std::exception& e ) {
        throw RestServiceException( "JSON parser error (%s) data (%s)", e.what(), data );
    }

    for ( BeatBinArray::iterator it=session->getBeats().begin(); it != session->getBeats().end(); ++it )
        session->getBeatDetector().addFrequencyEvent( (*it).getEvent(), (*it).getStartFreq(),  (*it).getEndFreq() );
}
Exemple #2
0
// ----------------------------------------------------------------------------
//
static bool music_matcher_load( Venue* venue, LPCSTR data, boolean clearFirst ) {
    SimpleJsonParser parser;

    std::vector<MusicSceneSelector> selections;

    try {
        parser.parse( data );

        JsonNodePtrArray selection_parsers = parser.getObjects();

        for ( JsonNode* selection : selection_parsers ) {
            UID selection_id = selection->get<UID>( "id" );
            CString selection_name = selection->get<CString>( "track" );
            CString selection_link = selection->get<CString>( "link" );
            MusicSelectorType selection_type = (MusicSelectorType)selection->get<int>( "type" );

            selections.push_back( MusicSceneSelector( selection_name, selection_link, selection_type, selection_id ) );
        }
    }
    catch ( std::exception& e ) {
        throw StudioException( "JSON parser error (%s) data (%s)", e.what(), data );
    }

    // Reload the selection map
    if ( clearFirst )
        venue->clearMusicMappings();

    venue->addMusicMappings( selections );

    return true;
}
Exemple #3
0
// ----------------------------------------------------------------------------
//
void HttpRestServices::edit_venue_update( Venue* venue, DMXHttpSession* session, CString& response, LPCSTR data, DWORD size, LPCSTR content_type )
{
    SimpleJsonParser parser;

    try {
        parser.parse( data );

        CString name = parser.get<CString>( "name" );
        CString description = parser.get<CString>( "description" );
        CString audio_capture_device = parser.get<CString>( "audio_capture_device" );
        float audio_boost = parser.get<float>( "audio_boost" );
        float audio_boost_floor = parser.get<float>( "audio_boost_floor" );
        int audio_sample_size = parser.get<int>( "audio_sample_size" );
        int auto_blackout = parser.get<int>( "auto_blackout" );
        bool track_fixtures = parser.get<bool>( "track_fixtures" );
        JsonNodePtrArray universeParsers = parser.getObjects("universes");

        std::vector<Universe> universes;

        for (  JsonNode* univ : universeParsers ) {
            unsigned id = univ->get<unsigned>( "id" );
            UniverseType type = (UniverseType)univ->get<unsigned>( "type" );
            CString dmx_config = univ->get<CString>( "dmx_config" );
            unsigned dmx_packet_delay_ms = univ->get<unsigned>( "packet_delay_ms" );
            unsigned dmx_minimum_delay_ms = univ->get<unsigned>( "minimum_delay_ms" );

            universes.emplace_back( id, type, dmx_config, dmx_packet_delay_ms, dmx_minimum_delay_ms );
        }

        venue->configure( name, description, audio_capture_device, audio_boost, audio_boost_floor, audio_sample_size, 
                          auto_blackout, track_fixtures, universes );
    }
    catch ( std::exception& e ) {
        throw RestServiceException( "JSON parser error (%s) data (%s)", e.what(), data );
    }
}