// ---------------------------------------------------------------------------- // void TrackInfoCacheFile::write( AudioTrackInfoCache& cache ) { TiXmlDocument doc; TiXmlElement root( "audio_track_info" ); for ( AudioTrackInfoCache::value_type pair : cache ) { TiXmlElement entry( "entry" ); add_text_element( entry, "link", pair.first ); add_text_element( entry, "id", pair.second.id ); add_text_element( entry, "song_type", pair.second.song_type ); TiXmlElement attributes( "attrs" ); add_attribute( attributes, "key", pair.second.key ); add_attribute( attributes, "mode", pair.second.mode ); add_attribute( attributes, "time_signature", pair.second.time_signature ); add_attribute( attributes, "energy", pair.second.energy ); add_attribute( attributes, "liveness", pair.second.liveness ); add_attribute( attributes, "tempo", pair.second.tempo ); add_attribute( attributes, "speechiness", pair.second.speechiness ); add_attribute( attributes, "acousticness", pair.second.acousticness ); add_attribute( attributes, "instrumentalness", pair.second.instrumentalness ); add_attribute( attributes, "duration", pair.second.duration ); add_attribute( attributes, "loudness", pair.second.loudness ); add_attribute( attributes, "valence", pair.second.valence ); add_attribute( attributes, "danceability", pair.second.danceability ); entry.InsertEndChild( attributes ); root.InsertEndChild( entry ); } doc.InsertEndChild( root ); doc.SaveFile( m_filename ); }
// ---------------------------------------------------------------------------- // void DefinitionWriter::writeFixtureDefinition( LPCSTR file_name, LPCSTR author, LPCSTR version, FixtureDefinitionPtrArray& definitions ) { TiXmlElement fixtures( "fixture_definitions" ); add_text_element( fixtures, "author", author ); add_text_element( fixtures, "version", version ); visit_ptr_array<FixtureDefinitionPtrArray>( fixtures, definitions ); TiXmlDocument doc; TiXmlDeclaration xml_decl( "1.0", "", "" ); doc.InsertEndChild( xml_decl ); doc.InsertEndChild( fixtures ); //doc.Print(); CString output_file = file_name; if ( doc.SaveFile( output_file ) ) studio.log_status( "Wrote fixture definitions to '%s'\n", output_file ); else studio.log_status( "Error writing to '%s'\n", output_file ); }
// ---------------------------------------------------------------------------- // void DefinitionWriter::visit( FixtureDefinition* fixture_definition ) { TiXmlElement fixture( "fixture" ); CString type( fixture_definition->convertFixtureTypeToText( fixture_definition->m_type ) ); type.MakeLower(); add_attribute( fixture, "type", (LPCSTR)type ); add_attribute( fixture, "channels", (int)fixture_definition->m_channels.size() ); add_text_element( fixture, "manufacturer", fixture_definition->m_manufacturer ); add_text_element( fixture, "model", fixture_definition->m_model ); TiXmlElement channels( "channels" ); visit_array<ChannelArray>( channels, fixture_definition->m_channels ); fixture.InsertEndChild( channels ); getParent().InsertEndChild( fixture ); }
// ---------------------------------------------------------------------------- // void DefinitionWriter::visit( ChannelValueRange* range ) { TiXmlElement range_element( "range" ); add_attribute( range_element, "start", range->m_start ); add_attribute( range_element, "end", range->m_end ); add_text_element( range_element, "name", range->m_name ); getParent().InsertEndChild( range_element ); }
// ---------------------------------------------------------------------------- // void DefinitionWriter::visit( Channel* channel ) { TiXmlElement channel_element( "channel" ); add_attribute( channel_element, "index", (DWORD)channel->m_channel_offset ); add_attribute( channel_element, "type", (LPCSTR)channel->convertChannelTypeToText( channel->m_type ) ); add_attribute( channel_element, "color", channel->isColor() ); add_attribute( channel_element, "blackout", channel->canBlackout() ); if ( channel->m_default_value ) add_attribute( channel_element, "value", channel->m_default_value ); if ( channel->m_pixel_index ) add_attribute( channel_element, "pixel", channel->m_pixel_index ); if ( channel->m_home_value ) add_attribute( channel_element, "home_value", channel->m_home_value ); if ( channel->m_head_number ) add_attribute( channel_element, "head", channel->m_head_number ); // Add dimmer if ( channel->isDimmer() ) { TiXmlElement dimmer( "dimmer" ); add_attribute( dimmer, "strobe", channel->m_dimmer_can_strobe ); add_attribute( dimmer, "lowest_intensity", channel->m_lowest_intensity ); add_attribute( dimmer, "highest_intensity", channel->m_highest_intensity ); add_attribute( dimmer, "off_intensity", channel->m_off_intensity ); channel_element.InsertEndChild( dimmer ); } // Add strobe if ( channel->isStrobe() ) { TiXmlElement strobe( "strobe" ); add_attribute( strobe, "speed_slow", channel->m_strobe_slow ); add_attribute( strobe, "speed_fast", channel->m_strobe_fast ); add_attribute( strobe, "off", channel->m_strobe_off ); } add_text_element( channel_element, "name", channel->m_name ); if ( channel->m_ranges.size() > 0 && channel->m_type != CHNLT_PAN && channel->m_type != CHNLT_TILT ) { TiXmlElement ranges( "ranges" ); visit_array<ChannelValueRangeArray>( ranges, channel->m_ranges ); channel_element.InsertEndChild( ranges ); } if ( channel->m_angles.size() > 0 ) { TiXmlElement angles( "angles" ); visit_array<ChannelAngleArray>( angles, channel->m_angles ); channel_element.InsertEndChild( angles ); } getParent().InsertEndChild( channel_element ); }