Package net.paulhertz.pixelaudio.io
Class AudioBrushSessionIO
java.lang.Object
net.paulhertz.pixelaudio.io.AudioBrushSessionIO
Session manifest writer/reader for brush sets.
Suggested filename:
bagatelle_rehearsalSet_session.json
Used in the example sketch
Bagatelle.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceAdapter that exposes brush data needed for writing a session.static interfaceFactory that rebuilds brush objects while reading a session.static final classPer-brush manifest record linking gesture and configuration files.static final classLoaded session data with rebuilt brush objects and source records.static final classSession-level metadata stored in an AudioBrush manifest. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static Stringprivate static voidputIfPresent(processing.data.JSONObject obj, String key, String value) static <B> AudioBrushSessionIO.SessionData<B>readSession(File sessionFile, AudioBrushSessionIO.BrushFactory<B> factory) Reads a session manifest and creates brush objects from linked resources.private static Stringrelativize(File baseDir, File target) private static voidrequireHeader(processing.data.JSONObject header, String expectedFormat, int expectedVersion) private static Stringprivate static StringsessionStem(File sessionFile) static <B> voidwriteSession(File sessionFile, List<B> brushes, AudioBrushSessionIO.BrushAdapter<B> adapter, AudioBrushSessionIO.SessionMeta meta, String gestureDirName, String configDirName) Writes a session manifest and its linked gesture/configuration files.
-
Field Details
-
FORMAT
Format identifier written to session manifest headers.- See Also:
-
VERSION
public static final int VERSIONSession manifest format version.- See Also:
-
-
Constructor Details
-
AudioBrushSessionIO
private AudioBrushSessionIO()
-
-
Method Details
-
writeSession
public static <B> void writeSession(File sessionFile, List<B> brushes, AudioBrushSessionIO.BrushAdapter<B> adapter, AudioBrushSessionIO.SessionMeta meta, String gestureDirName, String configDirName) throws IOException Writes a session manifest and its linked gesture/configuration files.- Type Parameters:
B- brush object type- Parameters:
sessionFile- destination session manifest filebrushes- brushes to serializeadapter- adapter that exposes data from each brushmeta- optional session metadatagestureDirName- folder name for linked gesture filesconfigDirName- folder name for linked configuration files- Throws:
IOException- if any file cannot be written
-
readSession
public static <B> AudioBrushSessionIO.SessionData<B> readSession(File sessionFile, AudioBrushSessionIO.BrushFactory<B> factory) throws IOException Reads a session manifest and creates brush objects from linked resources.- Type Parameters:
B- brush object type- Parameters:
sessionFile- session manifest filefactory- factory used to create brush objects- Returns:
- loaded session data
- Throws:
IOException- if the manifest or linked files cannot be read
-
sessionStem
-
relativize
-
requireHeader
private static void requireHeader(processing.data.JSONObject header, String expectedFormat, int expectedVersion) -
putIfPresent
-
safeId
-
nonBlank
-