Package javaforce.media
Class Music
java.lang.Object
javaforce.media.Music
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classEach audio sample for an Instrument must be 16bit, 44100Hz, monostatic interfacestatic classstatic classstatic classstatic classstatic classstatic classstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final float[]static final intstatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final byte -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintaddInstrument(String name) voidaddPattern(int nTracks) voidaddRegion(int iidx, int low, int high, int unityNote, int sample) booleanaddSamples(String name, short[] samples, int loopStart, int loopEnd, int sustainStart, int sustainEnd, float attenuation) booleanaddSamples(String name, String fn, int loopStart, int loopEnd, int sustainStart, int sustainEnd, float attenuation) voidaddTrack(int pattern) voidchannelApplyFX(int idx, byte fxcmd, int fxparam) voidchannelAttenuation(int idx, float value) voidchannelFreq(int idx, float freq) voidchannelKeyUp(int idx) voidchannelPan(int idx, float L, float R) voidchannelStop(int idx) voidclose()intinstrumentPlay(int idx, float volL, float volR, int note) Plays one note of an instrument thru a sound channel, returns idx of sound channel used.booleanbooleanstatic Music.Songload(InputStream is) static Music.Songbooleanload(Music.Song song) voidplayPattern(int patternIdx) voidplayRow(int patternIdx, int rowIdx) voidplaySong(boolean repeat) voidremoveInstrument(int idx) voidremovePattern(int pattern) voidremoveRegion(int iidx, int ridx) voidremoveSamples(int idx) voidremoveTrack(int pattern, int track) voidreplay()voidreset()intsamplePlay(int idx, float L, float R) Plays sample thru a sound channel, returns idx of sound channel used.booleanvoidsetListener(Music.Listener listener) voidsetMasterMusicVolume(float l, float r) Range: 0.0f -> 1.0fvoidsetMasterSoundVolume(float l, float r) Range: 0.0f -> 1.0fvoidsoundAttenuation(int idx, float value) voidintsoundLoad(short[] samples, int loopStart, int loopEnd, int sustainStart, int sustainEnd, float attenuation, int unityNote) Loads an audio file and returns its idxintsoundLoad(String fn, int loopStart, int loopEnd, int sustainStart, int sustainEnd, float attenuation) intsoundPlay(int idx, float volL, float volR, int note) Plays a sound, returns channel idx to modify during playback.voidsoundRemove(int idx) booleanstart(int milliSec, int soundChannels) Starts the sound output engine.voidstop()Stops the sound output engine, which stops music and sound output.voidStops current music (but sounds continue to play)
-
Field Details
-
VERSION
public static final int VERSION- See Also:
-
song
-
NOTE_NONE
public static final byte NOTE_NONE- See Also:
-
VOLCMD_NONE
public static final byte VOLCMD_NONE- See Also:
-
VOLCMD_SET_VOLUME
public static final byte VOLCMD_SET_VOLUME- See Also:
-
VOLCMD_SET_PANNING
public static final byte VOLCMD_SET_PANNING- See Also:
-
VOLCMD_SLIDE
public static final byte VOLCMD_SLIDE- See Also:
-
VOLCMD_PAN_SLIDE
public static final byte VOLCMD_PAN_SLIDE- See Also:
-
VOLCMD_SET_VOL_VIBRATE_SPEED
public static final byte VOLCMD_SET_VOL_VIBRATE_SPEED- See Also:
-
VOLCMD_SET_PAN_VIBRATE_SPEED
public static final byte VOLCMD_SET_PAN_VIBRATE_SPEED- See Also:
-
VOLCMD_TREMOLO
public static final byte VOLCMD_TREMOLO- See Also:
-
VOLCMD_PANBRELLO
public static final byte VOLCMD_PANBRELLO- See Also:
-
VOLCMD_MASTER_FLAG
public static final byte VOLCMD_MASTER_FLAG- See Also:
-
FXCMD_NONE
public static final byte FXCMD_NONE- See Also:
-
FXCMD_PORTAMENTO
public static final byte FXCMD_PORTAMENTO- See Also:
-
FXCMD_PORTAMENTO_TO_NOTE
public static final byte FXCMD_PORTAMENTO_TO_NOTE- See Also:
-
FXCMD_SET_VIBRATE_SPEED
public static final byte FXCMD_SET_VIBRATE_SPEED- See Also:
-
FXCMD_VIBRATO
public static final byte FXCMD_VIBRATO- See Also:
-
FXCMD_TREMOR
public static final byte FXCMD_TREMOR- See Also:
-
FXCMD_PATTERN_BREAK
public static final byte FXCMD_PATTERN_BREAK- See Also:
-
FXCMD_KEY_OFF
public static final byte FXCMD_KEY_OFF- See Also:
-
FXCMD_CUT_OFF
public static final byte FXCMD_CUT_OFF- See Also:
-
FXCMD_SET_INSTRUMENT
public static final byte FXCMD_SET_INSTRUMENT- See Also:
-
FXCMD_DELAY_START
public static final byte FXCMD_DELAY_START- See Also:
-
FXCMD_SAMPLE_OFFSET
public static final byte FXCMD_SAMPLE_OFFSET- See Also:
-
FXCMD_SET_BPM
public static final byte FXCMD_SET_BPM- See Also:
-
octave12
public static final float[] octave12
-
-
Constructor Details
-
Music
public Music()
-
-
Method Details
-
start
public boolean start(int milliSec, int soundChannels) Starts the sound output engine. After you can start music or sound playback. -
stop
public void stop()Stops the sound output engine, which stops music and sound output. -
load
-
load
-
load
-
save
-
close
public void close() -
reset
public void reset() -
replay
public void replay() -
setListener
-
playSong
public void playSong(boolean repeat) -
playPattern
public void playPattern(int patternIdx) -
playRow
public void playRow(int patternIdx, int rowIdx) -
stopMusic
public void stopMusic()Stops current music (but sounds continue to play) -
isRunning
public boolean isRunning() -
isPlaying
public boolean isPlaying() -
instrumentPlay
public int instrumentPlay(int idx, float volL, float volR, int note) Plays one note of an instrument thru a sound channel, returns idx of sound channel used.- Parameters:
idx- = instrument indexvolL- ,volR = left/right volume (0.0 - 1.0)note- = note to play (midi value)- Returns:
- idx to use with other Sound channel functions, -1 if can't play now
-
samplePlay
public int samplePlay(int idx, float L, float R) Plays sample thru a sound channel, returns idx of sound channel used.- Parameters:
idx- = instrument indexL- ,R = left/right volume (0.0 - 1.0)- Returns:
- idx to use with other Sound channel functions, -1 if can't play now
-
soundLoad
public int soundLoad(short[] samples, int loopStart, int loopEnd, int sustainStart, int sustainEnd, float attenuation, int unityNote) Loads an audio file and returns its idx -
soundLoad
public int soundLoad(String fn, int loopStart, int loopEnd, int sustainStart, int sustainEnd, float attenuation) -
soundRemove
public void soundRemove(int idx) -
soundClear
public void soundClear() -
soundAttenuation
public void soundAttenuation(int idx, float value) -
soundPlay
public int soundPlay(int idx, float volL, float volR, int note) Plays a sound, returns channel idx to modify during playback.- Parameters:
idx- = sound indexvolL- = left volume (0.0 - 1.0)volR- = right volume (0.0 - 1.0)note- = midi note to play (0-11)- Returns:
- idx to use with other Sound functions, -1 if can't play now
-
channelStop
public void channelStop(int idx) -
channelKeyUp
public void channelKeyUp(int idx) -
channelAttenuation
public void channelAttenuation(int idx, float value) -
channelPan
public void channelPan(int idx, float L, float R) -
channelFreq
public void channelFreq(int idx, float freq) -
channelApplyFX
public void channelApplyFX(int idx, byte fxcmd, int fxparam) -
addTrack
public void addTrack(int pattern) -
removeTrack
public void removeTrack(int pattern, int track) -
addPattern
public void addPattern(int nTracks) -
removePattern
public void removePattern(int pattern) -
addSamples
public boolean addSamples(String name, short[] samples, int loopStart, int loopEnd, int sustainStart, int sustainEnd, float attenuation) -
addSamples
-
removeSamples
public void removeSamples(int idx) -
addInstrument
-
removeInstrument
public void removeInstrument(int idx) -
addRegion
public void addRegion(int iidx, int low, int high, int unityNote, int sample) -
removeRegion
public void removeRegion(int iidx, int ridx) -
setMasterMusicVolume
public void setMasterMusicVolume(float l, float r) Range: 0.0f -> 1.0f -
setMasterSoundVolume
public void setMasterSoundVolume(float l, float r) Range: 0.0f -> 1.0f
-