<?xml version="1.0" encoding="UTF-8"?>
<!--
get http://xml.fiforms.org/xs3p/ and generate docs
xsltproc -o buzztrax.xsd.html /home/ensonic/download/xs3p-1.1.3/xs3p.xsl buzztrax.xsd
-->
<xsd:schema
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.buzztrax.org/"
  xmlns="http://www.buzztrax.org/"
  elementFormDefault="qualified">

  <!--
  <xsd:attribute name="key" type="xsd:string"/>
  <xsd:attribute name="value" type="xsd:string"/>
  <xsd:attribute name="voice" type="xsd:integer"/>
  <xsd:attribute name="voices" type="xsd:integer"/>
  <xsd:attribute name="id" type="xsd:string"/>
  <xsd:attribute name="type" type="xsd:string"/>
  <xsd:attribute name="index" type="xsd:integer"/>
  <xsd:attribute name="plugin-name" type="xsd:string"/>
  <xsd:attribute name="src" type="xsd:string"/>
  <xsd:attribute name="dst" type="xsd:string"/>
  <xsd:attribute name="gain" type="xsd:float"/>
  <xsd:attribute name="pan" type="xsd:float"/>
  <xsd:attribute name="machine" type="xsd:string"/>
  <xsd:attribute name="length" type="xsd:integer"/>
  <xsd:attribute name="time" type="xsd:integer"/>
  <xsd:attribute name="pattern" type="xsd:string"/>
  <xsd:attribute name="name" type="xsd:string"/>
  <xsd:attribute name="url" type="xsd:string"/>
  <xsd:attribute name="tracks" type="xsd:integer"/>
  <xsd:attribute name="loop" type="xsd:string"/>
  <xsd:attribute name="loop-start" type="xsd:integer"/>
  <xsd:attribute name="loop-end" type="xsd:integer"/>
  -->

  <xsd:element name="info" type="xsd:string"/>
  <xsd:element name="name" type="xsd:string"/>
  <xsd:element name="author" type="xsd:string"/>
  <xsd:element name="genre" type="xsd:string"/>
  <xsd:element name="bpm" type="xsd:integer"/>
  <xsd:element name="tpb" type="xsd:integer"/>
  <xsd:element name="bars" type="xsd:integer"/>
  <xsd:element name="create-dts" type="xsd:dateTime"/>
  <xsd:element name="change-dts" type="xsd:dateTime"/>

  <xsd:element name="meta">
    <xsd:annotation>
      <xsd:documentation>
        Song metadata, like title and genre.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="info" minOccurs="0" maxOccurs="1"/>
        <xsd:element ref="name" minOccurs="1" maxOccurs="1"/>
        <xsd:element ref="genre" minOccurs="0" maxOccurs="1"/>
        <xsd:element ref="author" minOccurs="0" maxOccurs="1"/>
        <xsd:element ref="create-dts" minOccurs="1" maxOccurs="1"/>
        <xsd:element ref="change-dts" minOccurs="0" maxOccurs="1"/>
        <xsd:element ref="bpm" minOccurs="1" maxOccurs="1"/>
        <xsd:element ref="tpb" minOccurs="1" maxOccurs="1"/>
        <xsd:element ref="bars" minOccurs="1" maxOccurs="1"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  
  <xsd:element name="wiredata">
    <xsd:annotation>
      <xsd:documentation>
        Pattern data for all voices of a machine.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:attribute name="name" use="required" type="xsd:string"/>
      <xsd:attribute name="value" use="required" type="xsd:string"/>
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="globaldata">
    <xsd:annotation>
      <xsd:documentation>
        Value of a dynamic parameter of a machine.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:attribute name="name" use="required" type="xsd:string"/>
      <xsd:attribute name="value" use="required" type="xsd:string"/>
    </xsd:complexType>
  </xsd:element>
  
  <xsd:element name="prefsdata">
    <xsd:annotation>
      <xsd:documentation>
        Value of a static parameter of a machine.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:attribute name="name" use="required" type="xsd:string"/>
      <xsd:attribute name="value" use="required" type="xsd:string"/>
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="property">
    <xsd:annotation>
      <xsd:documentation>
        State data.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:attribute name="key" use="required" type="xsd:string"/>
      <xsd:attribute name="value" use="required" type="xsd:string"/>
    </xsd:complexType>
  </xsd:element>
  
  <xsd:element name="properties">
    <xsd:annotation>
      <xsd:documentation>
        State key-value list.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="property" minOccurs="1" maxOccurs="unbounded"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  
  <xsd:element name="voicedata">
    <xsd:annotation>
      <xsd:documentation>
        Value of a dynamic parameter for one voice of a machine.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:attribute name="voice" use="required" type="xsd:integer"/>
      <xsd:attribute name="name" use="required" type="xsd:string"/>
      <xsd:attribute name="value" use="required" type="xsd:string"/>
    </xsd:complexType>
  </xsd:element>
  
  <xsd:element name="pattern">
    <xsd:annotation>
      <xsd:documentation>
        Control change fragment for one machine.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="tick" minOccurs="0" maxOccurs="unbounded"/>
      </xsd:sequence>
      <xsd:attribute name="name" use="required" type="xsd:string"/>
      <xsd:attribute name="length" use="required" type="xsd:integer"/>
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="patterns">
    <xsd:annotation>
      <xsd:documentation>
        List of control change fragments for one machine.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="pattern" minOccurs="1" maxOccurs="unbounded"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="machine">
    <xsd:annotation>
      <xsd:documentation>
        Media generator/effect/sink.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="prefsdata" minOccurs="0" maxOccurs="unbounded"/>
        <xsd:element ref="globaldata" minOccurs="0" maxOccurs="unbounded"/>
        <xsd:element ref="voicedata" minOccurs="0" maxOccurs="unbounded"/>
        <xsd:element ref="properties" minOccurs="0" maxOccurs="1"/>
        <xsd:element ref="patterns" minOccurs="0" maxOccurs="1"/>
      </xsd:sequence>
      <xsd:attribute name="type" use="required" type="xsd:string"/>
      <xsd:attribute name="id" use="required" type="xsd:string"/>
      <xsd:attribute name="plugin-name" type="xsd:string"/>
      <xsd:attribute name="voices"  type="xsd:integer"/>
    </xsd:complexType>
  </xsd:element>
    
  <xsd:element name="machines">
    <xsd:annotation>
      <xsd:documentation>
        List of machines.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="machine" minOccurs="0" maxOccurs="unbounded"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  
  <xsd:element name="wire-pattern">
    <xsd:annotation>
      <xsd:documentation>
        Control change fragment for one wire and pattern.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="tick" minOccurs="1" maxOccurs="unbounded"/>
      </xsd:sequence>
      <xsd:attribute name="pattern-id" use="required" type="xsd:string"/>
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="wire-patterns">
    <xsd:annotation>
      <xsd:documentation>
        List of control change fragments for one wire.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="wire-pattern" minOccurs="1" maxOccurs="unbounded"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="wire">
    <xsd:annotation>
      <xsd:documentation>
        Connection of two machines.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="properties" minOccurs="0" maxOccurs="1"/>
        <xsd:element ref="wire-patterns" minOccurs="0" maxOccurs="1"/>
      </xsd:sequence>
      <xsd:attribute name="src" use="required" type="xsd:string"/>
      <xsd:attribute name="dst" use="required" type="xsd:string"/>
      <xsd:attribute name="gain" use="required"  type="xsd:float"/>
      <xsd:attribute name="panorama"  type="xsd:float"/>
    </xsd:complexType>
  </xsd:element>
  
  <xsd:element name="wires">
    <xsd:annotation>
      <xsd:documentation>
        List of connections.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="wire" minOccurs="1" maxOccurs="unbounded"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  
  <xsd:element name="setup">
    <xsd:annotation>
      <xsd:documentation>
        Virtual gear setup (machines and wires).
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="properties" minOccurs="0" maxOccurs="unbounded"/>
        <xsd:element ref="machines" minOccurs="1" maxOccurs="1"/>
        <xsd:element ref="wires" minOccurs="1" maxOccurs="1"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  
  <xsd:element name="tick">
    <xsd:annotation>
      <xsd:documentation>
        Time slot.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="voicedata" minOccurs="0" maxOccurs="unbounded"/>
        <xsd:element ref="globaldata" minOccurs="0" maxOccurs="unbounded"/>
        <xsd:element ref="wiredata" minOccurs="0" maxOccurs="unbounded"/>
      </xsd:sequence>
      <xsd:attribute name="time" use="required" type="xsd:integer"/>
    </xsd:complexType>
  </xsd:element>
  
  <xsd:element name="label">
    <xsd:annotation>
      <xsd:documentation>
        Annotation for a tick.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:attribute name="time" use="required" type="xsd:integer"/>
      <xsd:attribute name="name" use="required" type="xsd:string"/>
    </xsd:complexType>
  </xsd:element>
  
  <xsd:element name="labels">
    <xsd:annotation>
      <xsd:documentation>
        List of annotations.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="label" minOccurs="0" maxOccurs="unbounded"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  
  <xsd:element name="position">
    <xsd:annotation>
      <xsd:documentation>
        Time location for a pattern in a track.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:attribute name="time" use="required" type="xsd:integer"/>
      <xsd:attribute name="pattern" use="required" type="xsd:string"/>
    </xsd:complexType>
  </xsd:element>
  
  <xsd:element name="track">
    <xsd:annotation>
      <xsd:documentation>
        Slot for pattern related to one machine.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="position" minOccurs="0" maxOccurs="unbounded"/>
      </xsd:sequence>
    <xsd:attribute name="index" use="required" type="xsd:integer"/>
    <xsd:attribute name="machine" use="required" type="xsd:string"/>
    </xsd:complexType>
  </xsd:element>
  
  <xsd:element name="tracks">
    <xsd:annotation>
      <xsd:documentation>
        List of tracks.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="track" minOccurs="1" maxOccurs="unbounded"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  
  <xsd:element name="sequence">
    <xsd:annotation>
      <xsd:documentation>
        Song structure build of a timeline and tracks.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="labels" minOccurs="1" maxOccurs="1"/>
        <xsd:element ref="tracks" minOccurs="1" maxOccurs="1"/>
      </xsd:sequence>
      <xsd:attribute name="length" use="required" type="xsd:integer"/>
      <xsd:attribute name="tracks" use="required" type="xsd:integer"/>
      <xsd:attribute name="loop" use="optional" type="xsd:string"/>
      <xsd:attribute name="loop-start" use="optional" type="xsd:integer"/>
      <xsd:attribute name="loop-end" use="optional" type="xsd:integer"/>
    </xsd:complexType>
  </xsd:element>
  
  <xsd:element name="wave">
    <xsd:annotation>
      <xsd:documentation>
        Wave in a wavetable.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:attribute name="index" use="required" type="xsd:integer"/>
      <xsd:attribute name="name" use="required" type="xsd:string"/>
      <xsd:attribute name="uri" use="required" type="xsd:string"/>
    </xsd:complexType>
  </xsd:element>
  
  <xsd:element name="wavetable">
    <xsd:annotation>
      <xsd:documentation>
        List of waves.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="wave" minOccurs="0" maxOccurs="unbounded"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  
  <xsd:element name="buzztrax">
    <xsd:annotation>
      <xsd:documentation>
        Toplevel elements for a buzztrax song.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="meta" minOccurs="1" maxOccurs="1"/>
        <xsd:element ref="setup" minOccurs="1" maxOccurs="1"/>
        <xsd:element ref="sequence" minOccurs="1" maxOccurs="1"/>
        <xsd:element ref="wavetable" minOccurs="0" maxOccurs="1"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>
