DixShtix

com.dixshtix.niff
Class ToMidi

java.lang.Object
  |
  +--com.dixshtix.niff.ToMidi
All Implemented Interfaces:
NiffParserListener

public class ToMidi
extends java.lang.Object
implements NiffParserListener

Dump chunk information about a niff file.
Based on code placed in the Public Domain 1995,1996 Timothy Butler.


Field Summary
protected  java.util.List conductor
           
protected  java.lang.Object current
           
protected  FourByteConstant currentChunk
           
protected  int measureTimeSlice
           
protected  int noteEnd
           
protected  int noteMidiValue
           
protected  boolean notePending
           
protected  int noteStaffStep
           
protected  int noteStart
           
protected  int noteVelocity
           
protected  int otherTimeSlice
           
protected  java.io.BufferedOutputStream out
          Output stream.
protected  int partAbbreviation
           
protected  int partCable
           
protected  int partChannel
           
protected  java.lang.Integer partID
           
protected  int partName
           
protected  java.util.Map parts
           
protected  int partTranspose
           
static java.lang.String Progname
          Program name.
static java.lang.String rcsid
          Source file update.
protected  Opus smf
           
protected  int tempoNoteValue
           
protected  int tempoNoteValueBottom
           
protected  int tempoNoteValueTop
           
protected  int timeSignatureTopNumber
           
protected  int timeSliceType
           
 
Constructor Summary
ToMidi(java.io.BufferedOutputStream out)
          Constructor.
 
Method Summary
 void addEvent(java.util.List events, int time, EventType type, java.lang.Object[] params, boolean prepend)
           
 void beginContainerChunk(FourByteConstant containerType, FourByteConstant chunkType, NiffParserContext context)
           
 void beginMiscChunk(java.lang.String chunkType, NiffParserContext context)
           
 void beginNiffChunk(FourByteConstant chunkType, int expectedLength, NiffParserContext context)
          Handle known-length Niff Chunks which may have Tags appended to them.
 void beginNiffTag(byte tagID, NiffParserContext context)
           
 void beginRiffChunk(FourByteConstant chunkType, NiffParserContext context)
           
 void byteAttribute(java.lang.String attribute, int value, NiffParserContext context)
           
static int cvtStaffStepToMidiNote(byte staffStep, java.util.Map part)
          Convert staff step (7 note names) to Midi notes (12 semitones).
 void dataBytes(byte[] data, int offset, int length, NiffParserContext context)
           
 void endContainerChunk(FourByteConstant containerType, FourByteConstant chunkType, NiffParserContext context)
           
 void endMiscChunk(java.lang.String chunkType, NiffParserContext context)
           
 void endNiffChunk(FourByteConstant chunkType, NiffParserContext context)
          Finish Niff Chunk and any Tags.
 void endNiffTag(byte tagID, NiffParserContext context)
           
 void endRiffChunk(FourByteConstant chunkType, NiffParserContext context)
           
 void fillMiscChunk(java.lang.String chunkType, NiffParserContext context)
           
 void fillNiffChunk(FourByteConstant chunkType, NiffParserContext context)
           
 void fillNiffTag(byte tagID, NiffParserContext context)
           
 void fillRiffChunk(FourByteConstant chunkType, NiffParserContext context)
           
 void fontidxAttribute(java.lang.String attribute, int value, NiffParserContext context)
           
 void fourccAttribute(java.lang.String attribute, FourByteConstant value, NiffParserContext context)
           
 void longAttribute(java.lang.String attribute, int value, NiffParserContext context)
           
static void main(java.lang.String[] args)
          Main routine for opening a RIFF file and dumping schematic of contents to the System.out;
 void rationalAttribute(java.lang.String attribute, int top, int bottom, NiffParserContext context)
           
 void shortAttribute(java.lang.String attribute, int value, NiffParserContext context)
          Handle short (2-byte signed integer) attributes.
 void signedbyteAttribute(java.lang.String attribute, byte value, NiffParserContext context)
          Handle signedbyte (1-byte signed integer) attributes.
 void stringAttribute(java.lang.String attribute, java.lang.String value, NiffParserContext context)
           
 java.lang.String stringOffsetToString(int stroffset, byte[] strings)
           
 void stroffsetAttribute(java.lang.String attribute, int value, NiffParserContext context)
           
(package private) static void usage(java.io.PrintStream ps)
          List program arguments for user.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

rcsid

public static java.lang.String rcsid
Source file update.

Progname

public static java.lang.String Progname
Program name.

out

protected java.io.BufferedOutputStream out
Output stream.

current

protected java.lang.Object current

currentChunk

protected FourByteConstant currentChunk

smf

protected Opus smf

partID

protected java.lang.Integer partID

partChannel

protected int partChannel

partCable

protected int partCable

partTranspose

protected int partTranspose

partName

protected int partName

partAbbreviation

protected int partAbbreviation

parts

protected java.util.Map parts

conductor

protected java.util.List conductor

timeSliceType

protected int timeSliceType

measureTimeSlice

protected int measureTimeSlice

otherTimeSlice

protected int otherTimeSlice

timeSignatureTopNumber

protected int timeSignatureTopNumber

tempoNoteValue

protected int tempoNoteValue

tempoNoteValueTop

protected int tempoNoteValueTop

tempoNoteValueBottom

protected int tempoNoteValueBottom

notePending

protected boolean notePending

noteVelocity

protected int noteVelocity

noteMidiValue

protected int noteMidiValue

noteStaffStep

protected int noteStaffStep

noteStart

protected int noteStart

noteEnd

protected int noteEnd
Constructor Detail

ToMidi

public ToMidi(java.io.BufferedOutputStream out)
Constructor.
Method Detail

cvtStaffStepToMidiNote

public static int cvtStaffStepToMidiNote(byte staffStep,
                                         java.util.Map part)
Convert staff step (7 note names) to Midi notes (12 semitones). Ignores accidentals and key signatures.

addEvent

public void addEvent(java.util.List events,
                     int time,
                     EventType type,
                     java.lang.Object[] params,
                     boolean prepend)

stringOffsetToString

public java.lang.String stringOffsetToString(int stroffset,
                                             byte[] strings)

usage

static void usage(java.io.PrintStream ps)
List program arguments for user.

main

public static void main(java.lang.String[] args)
Main routine for opening a RIFF file and dumping schematic of contents to the System.out;

beginContainerChunk

public void beginContainerChunk(FourByteConstant containerType,
                                FourByteConstant chunkType,
                                NiffParserContext context)
Specified by:
beginContainerChunk in interface NiffParserListener

beginMiscChunk

public void beginMiscChunk(java.lang.String chunkType,
                           NiffParserContext context)
Specified by:
beginMiscChunk in interface NiffParserListener

beginNiffChunk

public void beginNiffChunk(FourByteConstant chunkType,
                           int expectedLength,
                           NiffParserContext context)
Handle known-length Niff Chunks which may have Tags appended to them.

If ChunkLengthTable.NiffInfo then Opus.setFormat(int) to 1.

Specified by:
beginNiffChunk in interface NiffParserListener

beginNiffTag

public void beginNiffTag(byte tagID,
                         NiffParserContext context)
Specified by:
beginNiffTag in interface NiffParserListener

beginRiffChunk

public void beginRiffChunk(FourByteConstant chunkType,
                           NiffParserContext context)
Specified by:
beginRiffChunk in interface NiffParserListener

endContainerChunk

public void endContainerChunk(FourByteConstant containerType,
                              FourByteConstant chunkType,
                              NiffParserContext context)
Specified by:
endContainerChunk in interface NiffParserListener

endMiscChunk

public void endMiscChunk(java.lang.String chunkType,
                         NiffParserContext context)
Specified by:
endMiscChunk in interface NiffParserListener

endNiffChunk

public void endNiffChunk(FourByteConstant chunkType,
                         NiffParserContext context)
Finish Niff Chunk and any Tags.

If ChunkLengthTable.Part then create part, with placeholders for strings.

Specified by:
endNiffChunk in interface NiffParserListener

endNiffTag

public void endNiffTag(byte tagID,
                       NiffParserContext context)
Specified by:
endNiffTag in interface NiffParserListener

endRiffChunk

public void endRiffChunk(FourByteConstant chunkType,
                         NiffParserContext context)
Specified by:
endRiffChunk in interface NiffParserListener

fillMiscChunk

public void fillMiscChunk(java.lang.String chunkType,
                          NiffParserContext context)
Specified by:
fillMiscChunk in interface NiffParserListener

fillNiffChunk

public void fillNiffChunk(FourByteConstant chunkType,
                          NiffParserContext context)
Specified by:
fillNiffChunk in interface NiffParserListener

fillNiffTag

public void fillNiffTag(byte tagID,
                        NiffParserContext context)
Specified by:
fillNiffTag in interface NiffParserListener

fillRiffChunk

public void fillRiffChunk(FourByteConstant chunkType,
                          NiffParserContext context)
Specified by:
fillRiffChunk in interface NiffParserListener

byteAttribute

public void byteAttribute(java.lang.String attribute,
                          int value,
                          NiffParserContext context)
Specified by:
byteAttribute in interface NiffParserListener

dataBytes

public void dataBytes(byte[] data,
                      int offset,
                      int length,
                      NiffParserContext context)
Specified by:
dataBytes in interface NiffParserListener

fontidxAttribute

public void fontidxAttribute(java.lang.String attribute,
                             int value,
                             NiffParserContext context)
Specified by:
fontidxAttribute in interface NiffParserListener

fourccAttribute

public void fourccAttribute(java.lang.String attribute,
                            FourByteConstant value,
                            NiffParserContext context)
Specified by:
fourccAttribute in interface NiffParserListener

longAttribute

public void longAttribute(java.lang.String attribute,
                          int value,
                          NiffParserContext context)
Specified by:
longAttribute in interface NiffParserListener

rationalAttribute

public void rationalAttribute(java.lang.String attribute,
                              int top,
                              int bottom,
                              NiffParserContext context)
Specified by:
rationalAttribute in interface NiffParserListener

shortAttribute

public void shortAttribute(java.lang.String attribute,
                           int value,
                           NiffParserContext context)
Handle short (2-byte signed integer) attributes.

If ChunkLengthTable.NiffInfo then Opus.setTicks(int) to "midiClocksPerQuarter" unless -1.

If ChunkLengthTable.Part then save partID for part Creation.

Specified by:
shortAttribute in interface NiffParserListener

signedbyteAttribute

public void signedbyteAttribute(java.lang.String attribute,
                                byte value,
                                NiffParserContext context)
Handle signedbyte (1-byte signed integer) attributes.

If ChunkLengthTable.Part then save midiChannel, midiCable and transpose for part Creation.

Specified by:
signedbyteAttribute in interface NiffParserListener

stringAttribute

public void stringAttribute(java.lang.String attribute,
                            java.lang.String value,
                            NiffParserContext context)
Specified by:
stringAttribute in interface NiffParserListener

stroffsetAttribute

public void stroffsetAttribute(java.lang.String attribute,
                               int value,
                               NiffParserContext context)
Specified by:
stroffsetAttribute in interface NiffParserListener

DixShtix