Class AudioBrushSessionIO

java.lang.Object
net.paulhertz.pixelaudio.io.AudioBrushSessionIO

public final class AudioBrushSessionIO extends Object
Session manifest writer/reader for brush sets. Suggested filename: bagatelle_rehearsalSet_session.json Used in the example sketch Bagatelle.
  • Field Details

  • 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 file
      brushes - brushes to serialize
      adapter - adapter that exposes data from each brush
      meta - optional session metadata
      gestureDirName - folder name for linked gesture files
      configDirName - 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 file
      factory - factory used to create brush objects
      Returns:
      loaded session data
      Throws:
      IOException - if the manifest or linked files cannot be read
    • sessionStem

      private static String sessionStem(File sessionFile)
    • relativize

      private static String relativize(File baseDir, File target)
    • requireHeader

      private static void requireHeader(processing.data.JSONObject header, String expectedFormat, int expectedVersion)
    • putIfPresent

      private static void putIfPresent(processing.data.JSONObject obj, String key, String value)
    • safeId

      private static String safeId(String id)
    • nonBlank

      private static String nonBlank(String value, String fallback)