Public Member Functions | |
abstract boolean | open () |
abstract boolean | close () |
abstract void | discardBufferedPackets () |
abstract boolean | flush () |
abstract int | getBufferredMessagesCount () |
abstract int | getBufferedMessagesSize () |
abstract void | addArtifactPacket (int id, MuseArtifactPacket packet) |
abstract void | addDataPacket (int id, MuseDataPacket packet) |
abstract void | addAnnotationString (int id, String annotation) |
abstract void | addAnnotation (int id, AnnotationData annotation) |
abstract void | addConfiguration (int id, MuseConfiguration configuration) |
abstract void | addVersion (int id, MuseVersion version) |
abstract void | addComputingDeviceConfiguration (int id, ComputingDeviceConfiguration configuration) |
abstract void | addDsp (int id, DspData dsp) |
abstract void | setTimestampMode (TimestampMode mode) |
abstract void | setTimestamp (long timestamp) |
Static Public Member Functions | |
static native MuseFileWriter | getFileWriter (MuseFile file) |
This class manages saving Muse packets and other data into a file, which can later be read and replayed by MusePlayer. Google Protobuf is used to store the information. For better control, data is not written to the file immediately, but stored in a buffer instead. The buffer then can be flushed to a file or discarded.
Note that upon creation of a MuseFileWriter , an Annotation and the ComputingDeviceConfiguration are automatically written out to the file. The annotation contains the app's name and version and libmuse version. If app's name and version can not be determined, they will be empty strings. The ComputingDeviceConfiguration contains hardware information for the computing device. If any information fields can not be determined, they will be empty strings.
Threading: It is thread safe, so you can call write()/get()/flush()/discard() operations from different threads.
|
abstract |
Adds annotation data structure to the buffer. Similar to addAnnotationString(), but this method allows you to extra fields. Empty fields in annotation struct won't be added to protobuf. If annotation.data field is empty, method returns immediately.
id | The id of the device generating the annotation. This is arbitrary and is used to differentiate data from multiple devices in a single file. |
annotation | The annotation data to add. |
|
abstract |
Adds an annotation string to the buffer. It may be useful if you want to log specific events. This is a simplified version of addAnnotation(). Use this method if you want to add one string to protobuf. Use addAnnotation() for more advanced options. This function does nothing if annotation is empty.
id | The id of the device generating the packet. This is arbitrary and is used to differentiate data from multiple devices in a single file. |
annotation | The annotation string to add. |
|
abstract |
Adds MuseArtifactPacket to the buffer.
id | The id of the device generating the packet. This is arbitrary and is used to differentiate data from multiple devices in a single file. |
packet | The artifact packet to add. |
|
abstract |
Adds information about the running device to the buffer.
id | The id of the device saving the configuration. This is arbitrary and is used to differentiate data from multiple devices in a single file. |
configuration | The device configuration data to add. |
|
abstract |
Adds MuseConfiguration to the buffer.
id | The id of the device saving the configuration. This is arbitrary and is used to differentiate data from multiple devices in a single file. |
configuration | The configuration data to add. |
|
abstract |
Adds MuseDataPacket to the buffer. All current packets are supported.
id | The id of the device generating the packet. This is arbitrary and is used to differentiate data from multiple devices in a single file. |
packet | The data packet to add. |
|
abstract |
With this method you can save your custom data. Checkout protobuf schema for details: http://developer.choosemuse.com/file-formats/muse
id | The id of the device saving the data. This is arbitrary and is used to differentiate data from multiple devices in a single file. |
dsp | The data to store. |
|
abstract |
Adds MuseVersion to the buffer.
id | The id of the device saving the version. This is arbitrary and is used to differentiate data from multiple devices in a single file. |
version | The version data to add. |
|
abstract |
Closes the file. Calls MuseFile.close() You don't have to call close explicitly unless you want to close file immediately. close is called automatically, when the file writer object is destroyed.
false
if the file could not be closed for any reason. true
otherwise.
|
abstract |
Removes all saved messages from the memory.
|
abstract |
Flashes saved messages to the disk. Calls MuseFile.write()
false
if can not write to file for any reason. true
otherwise.
|
abstract |
Returns the size of saved messages in bytes.
|
abstract |
Returns number of saved messages
|
static |
Returns an instance of file writer. Automatically opens a file.
|
abstract |
Opens a file if it exists or creates a new one. If file already exists, all new messages will be appended at the end. Use this method if you explicitly closed file and want to open it again. Calls MuseFile.open()
false
if the file could not be opened for any reason. true
otherwise.
|
abstract |
Set the timestamp for the next message to be written.
This only does anything in explicit timestamp mode. In explicit mode, the timestamp set by set_timestamp applies to the next message and all subsequent messages. If set_timestamp is not called, then the timestamp is 0.
In all other modes, calling set_timestamp causes an assert failure – the app crashes in debug mode, and it is a noop in release mode.
The timestamp is in microseconds since some epoch (usually Jan 1, 1970).
timestamp | The time to use for the timestamp in microseconds. |
|
abstract |
Set the timestamp mode.
By default, the mode is TimestampMode.LEGACY
mode | The timestamp mode to set. |