Rerun C++ SDK
Loading...
Searching...
No Matches
rerun::archetypes::AssetAudio Struct Reference

Archetype: An audio file, stored as-is (.aac, .flac, .m4a, .mp3, .ogg, .wav). More...

#include <rerun/archetypes/asset_audio.hpp>

Public Member Functions

 AssetAudio (AssetAudio &&other)=default
 
 AssetAudio (const AssetAudio &other)=default
 
AssetAudiooperator= (const AssetAudio &other)=default
 
AssetAudiooperator= (AssetAudio &&other)=default
 
 AssetAudio (rerun::components::Blob _blob)
 
AssetAudio with_blob (const rerun::components::Blob &_blob) &&
 The asset's bytes.
 
AssetAudio with_many_blob (const Collection< rerun::components::Blob > &_blob) &&
 This method makes it possible to pack multiple blob in a single component batch.
 
AssetAudio with_media_type (const rerun::components::MediaType &_media_type) &&
 The Media Type of the asset.
 
AssetAudio with_many_media_type (const Collection< rerun::components::MediaType > &_media_type) &&
 This method makes it possible to pack multiple media_type in a single component batch.
 
Collection< ComponentColumncolumns (const Collection< uint32_t > &lengths_)
 Partitions the component data into multiple sub-batches.
 
Collection< ComponentColumncolumns ()
 Partitions the component data into unit-length sub-batches.
 

Static Public Member Functions

static Result< AssetAudiofrom_file_path (const std::filesystem::path &path)
 Creates a new AssetAudio from the file contents at path.
 
static AssetAudio from_file_contents (rerun::Collection< uint8_t > bytes, std::optional< rerun::components::MediaType > media_type={})
 Creates a new AssetAudio from the given bytes.
 
static AssetAudio update_fields ()
 Update only some specific fields of a AssetAudio.
 
static AssetAudio clear_fields ()
 Clear all the fields of a AssetAudio.
 

Public Attributes

std::optional< ComponentBatchblob
 The asset's bytes.
 
std::optional< ComponentBatchmedia_type
 The Media Type of the asset.
 

Static Public Attributes

static constexpr const char ArchetypeName [] = "rerun.archetypes.AssetAudio"
 The name of the archetype as used in ComponentDescriptors.
 
static constexpr auto Descriptor_blob
 ComponentDescriptor for the blob field.
 
static constexpr auto Descriptor_media_type
 ComponentDescriptor for the media_type field.
 

Detailed Description

Archetype: An audio file, stored as-is (.aac, .flac, .m4a, .mp3, .ogg, .wav).

The audio is considered to start playing at the time it was logged, so log it on a temporal timeline (duration or timestamp) at the point where playback should begin.

Example

Simple audio asset

#include <rerun.hpp>
#include <iostream>
int main(int argc, char* argv[]) {
if (argc <2) {
std::cerr <<"Usage: " <<argv[0]
<<" <path_to_audio.[aac|flac|m4a|mp3|ogg|wav]>" <<std::endl;
return 1;
}
const auto path = argv[1];
const auto rec = rerun::RecordingStream("rerun_example_asset_audio");
rec.spawn().exit_on_failure();
rec.set_time_duration_secs("time", 0.0);
rec.log("audio", rerun::AssetAudio::from_file_path(path).value_or_throw());
}
A RecordingStream handles everything related to logging data into Rerun.
Definition recording_stream.hpp:63

This type is unstable and may change significantly in a way that the data won't be backwards compatible.

Member Function Documentation

◆ from_file_path()

static Result< AssetAudio > rerun::archetypes::AssetAudio::from_file_path ( const std::filesystem::path &  path)
static

Creates a new AssetAudio from the file contents at path.

The MediaType will be guessed from the file extension.

If no MediaType can be guessed at the moment, the Rerun Viewer will try to guess one from the data at playback-time. If it can't, playback will fail with an error.

◆ from_file_contents()

static AssetAudio rerun::archetypes::AssetAudio::from_file_contents ( rerun::Collection< uint8_t >  bytes,
std::optional< rerun::components::MediaType media_type = {} 
)
inlinestatic

Creates a new AssetAudio from the given bytes.

If no MediaType is specified, the Rerun Viewer will try to guess one from the data at playback-time. If it can't, playback will fail with an error.

◆ with_many_blob()

AssetAudio rerun::archetypes::AssetAudio::with_many_blob ( const Collection< rerun::components::Blob > &  _blob) &&
inline

This method makes it possible to pack multiple blob in a single component batch.

This only makes sense when used in conjunction with columns. with_blob should be used when logging a single row's worth of data.

◆ with_media_type()

AssetAudio rerun::archetypes::AssetAudio::with_media_type ( const rerun::components::MediaType _media_type) &&
inline

The Media Type of the asset.

For instance:

  • audio/aac (raw ADTS stream)
  • audio/flac
  • audio/mp4 (M4A)
  • audio/mpeg (MP3)
  • audio/ogg
  • audio/wav

Any audio media type can be stored. Which ones the viewer can decode depends on the viewer version.

If omitted, the viewer will try to guess from the data blob. If it cannot guess, it won't be able to play the asset.

◆ with_many_media_type()

AssetAudio rerun::archetypes::AssetAudio::with_many_media_type ( const Collection< rerun::components::MediaType > &  _media_type) &&
inline

This method makes it possible to pack multiple media_type in a single component batch.

This only makes sense when used in conjunction with columns. with_media_type should be used when logging a single row's worth of data.

◆ columns() [1/2]

Collection< ComponentColumn > rerun::archetypes::AssetAudio::columns ( const Collection< uint32_t > &  lengths_)

Partitions the component data into multiple sub-batches.

Specifically, this transforms the existing ComponentBatch data into ComponentColumns instead, via ComponentBatch::partitioned.

This makes it possible to use RecordingStream::send_columns to send columnar data directly into Rerun.

The specified lengths must sum to the total length of the component batch.

◆ columns() [2/2]

Collection< ComponentColumn > rerun::archetypes::AssetAudio::columns ( )

Partitions the component data into unit-length sub-batches.

This is semantically similar to calling columns with std::vector<uint32_t>(n, 1), where n is automatically guessed.

Member Data Documentation

◆ media_type

std::optional<ComponentBatch> rerun::archetypes::AssetAudio::media_type

The Media Type of the asset.

For instance:

  • audio/aac (raw ADTS stream)
  • audio/flac
  • audio/mp4 (M4A)
  • audio/mpeg (MP3)
  • audio/ogg
  • audio/wav

Any audio media type can be stored. Which ones the viewer can decode depends on the viewer version.

If omitted, the viewer will try to guess from the data blob. If it cannot guess, it won't be able to play the asset.

◆ Descriptor_blob

constexpr auto rerun::archetypes::AssetAudio::Descriptor_blob
staticconstexpr
Initial value:
= ComponentDescriptor(
ArchetypeName, "AssetAudio:blob", Loggable<rerun::components::Blob>::ComponentType
)
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition asset_audio.hpp:75

ComponentDescriptor for the blob field.

◆ Descriptor_media_type

constexpr auto rerun::archetypes::AssetAudio::Descriptor_media_type
staticconstexpr
Initial value:
= ComponentDescriptor(
ArchetypeName, "AssetAudio:media_type",
Loggable<rerun::components::MediaType>::ComponentType
)

ComponentDescriptor for the media_type field.


The documentation for this struct was generated from the following file: