Package sidplay

Klasse Player

Alle implementierten Schnittstellen:
Consumer<VIC>, SIDListener, IMOS6510Extension, Ultimate64, VideoDriver

public class Player extends HardwareEnsemble implements VideoDriver, SIDListener, IMOS6510Extension
The player adds some music player capabilities to the HardwareEnsemble.
Autor:
Ken Händel
  • Felddetails

    • LOG

      private static final Logger LOG
    • LAST_MODIFIED

      public static final Calendar LAST_MODIFIED
      Build date calculated from our own modified time
    • PAUSE_SLEEP_TIME

      private static final int PAUSE_SLEEP_TIME
      Timeout (in ms) for sleeping, if the player is paused.
      Siehe auch:
    • QUIT_MAX_WAIT_TIME

      private static final int QUIT_MAX_WAIT_TIME
      Timeout (in ms) for quitting the player.
      Siehe auch:
    • PREV_SONG_TIMEOUT

      private static final int PREV_SONG_TIMEOUT
      Previous song select timeout (< 4 secs).
      Siehe auch:
    • RUN

      private static final String RUN
      Auto-start commands.
      Siehe auch:
    • SYS

      private static final String SYS
      Auto-start commands.
      Siehe auch:
    • LOAD

      private static final String LOAD
      Auto-start commands.
      Siehe auch:
    • stateProperty

      private ObjectProperty<State> stateProperty
      Music player state.
    • timer

      private Timer timer
      Play timer.
    • playList

      private PlayList playList
      Play list.
    • tune

      private SidTune tune
      Currently played tune.
    • command

      private String command
      Auto-start command to be typed-in after reset (PETSCII).
    • playerThread

      private Thread playerThread
      Music player thread.
    • interactivityHook

      private Consumer<Player> interactivityHook
      Called each time a chunk of music has been played.
    • whatsSidHook

      private Consumer<MusicInfoWithConfidenceBean> whatsSidHook
      Called after WhatsSID has detected a tune.
    • playAddrHook

      private Function<Integer,Integer> playAddrHook
      Override the player address of the tune.
    • audioAndDriver

      Currently used audio and corresponding audio driver.

      Note: If an audio driver has been set externally by setAudioDriver(AudioDriver), audio is null!

    • uncaughtExceptionHandler

      private Thread.UncaughtExceptionHandler uncaughtExceptionHandler
      Uncaught Player exception handler.
    • checkDefaultLengthInRecordMode

      private boolean checkDefaultLengthInRecordMode
      Check the default length in record mode (default is true).

      Note: In record mode the player requires a default length. If it is not available, it will be limited to 180s.

    • checkLoopOffInRecordMode

      private boolean checkLoopOffInRecordMode
      Set the check loop off in record mode (default is true).

      Note: In record mode the player must not loop forever. However, it can be forced to not be checked.

    • forceCheckSongLength

      private boolean forceCheckSongLength
      Force check song length (default is false).

      Note: If song length has been reached, the player ends the current song, but not in RESET mode. However, this can be forced by this switch.

    • autodetection

      private final Autodetection autodetection
      Autodetection of SID chip configuration.
    • firstPlayListEntryIsOne

      private boolean firstPlayListEntryIsOne
      The first entry of the playlist is the first song (otherwise start song).
    • sidBuilder

      private SIDBuilder sidBuilder
      SID builder being used to create SID chips (real hardware or emulation).
    • stil

      private STIL stil
      SID tune information list.
    • sidDatabase

      private SidDatabase sidDatabase
      Song length database.
    • recordingFilenameProvider

      private Function<SidTune,String> recordingFilenameProvider
      Create a base name of a filename to be used for recording.
    • requiredSIDs

      private final BiFunction<Integer,SIDEmu,SIDEmu> requiredSIDs
      Insert required SIDs. Use SID builder to create/destroy SIDs.
    • noSIDs

      private final BiFunction<Integer,SIDEmu,SIDEmu> noSIDs
      Eject all SIDs.
    • sidLocator

      private final IntFunction<Integer> sidLocator
      Set the base address of required SIDs.
    • pauseListener

      private final PropertyChangeListener pauseListener
      Player paused? Stop audio production.
    • videoDrivers

      private final List<VideoDriver> videoDrivers
      Consumer for VIC screen output as ARGB data
    • sidListeners

      private final List<SIDListener> sidListeners
      Consumer for SID register writes
    • mos6510Extensions

      private final List<IMOS6510Extension> mos6510Extensions
      Consumer for CPU JMP/JSR instructions
    • fastForwardVICFrames

      private int fastForwardVICFrames
      Fast-forward: skipped VIC frames.
    • fingerPrintMatcher

      private IFingerprintMatcher fingerPrintMatcher
      WhatsSID?
    • whatsSidEvent

      private WhatsSidEvent whatsSidEvent
      Regularly scheduled event for tune recognition.
    • playerRunnable

      private final Runnable playerRunnable
      Player runnable to play music in a background thread.
  • Konstruktordetails

    • Player

      public Player(IConfig config)
      Create a Music Player.
      Parameter:
      config - configuration
    • Player

      public Player(IConfig config, Function<EventScheduler,MOS6510> cpuCreator)
      Create a Music Player.
      Parameter:
      config - configuration
      cpuCreator - creator of the CPU class implementation to be used
  • Methodendetails

    • initializeTmpDir

      public static void initializeTmpDir(IConfig config)
      Create temporary directory, if it does not exist.
      E.g. Recordings and converted tapes are saved here!
    • getFingerPrintMatcher

      public IFingerprintMatcher getFingerPrintMatcher()
      Get a fingerprint matcher.
      Gibt zurück:
      fingerprint matcher
    • setFingerPrintMatcher

      public void setFingerPrintMatcher(IFingerprintMatcher fingerPrintMatcher)
      Set a fingerprint matcher.
      Parameter:
      fingerPrintMatcher - a fingerprint matcher
    • updateSIDChipConfiguration

      public final void updateSIDChipConfiguration()
      Call to update SID chips each time SID configuration has been changed thread-safe.
    • configureVICs

      public final void configureVICs(Consumer<VIC> action)
      Call to configure VIC chips thread-safe.
      Parameter:
      action - VIC configuration action
    • configureSIDs

      public final void configureSIDs(BiConsumer<Integer,SIDEmu> action)
      Configure all available SIDs thread-safe.
      Parameter:
      action - SID chip consumer
    • configureSID

      public final void configureSID(int chipNum, Consumer<SIDEmu> action)
      Configure one specific SID thread-safe.
      Parameter:
      chipNum - SID chip number
      action - SID chip consumer
    • configureMixer

      public final void configureMixer(Consumer<Mixer> action)
      Configure the mixer, optionally implemented by SID builder thread-safe.
      Parameter:
      action - mixer consumer
    • executeInPlayerThread

      private void executeInPlayerThread(String eventName, Runnable runnable)
      The runnable is executed immediately in player thread or scheduled thread-safe.
      Parameter:
      eventName - event name for scheduling
      runnable - runnable to execute in player thread
    • reset

      public final void reset()
      Power-on C64 system.
      Setzt außer Kraft:
      reset in Klasse HardwareEnsemble
    • setCommand

      private void setCommand(String command)
      Enter a basic command after reset (PETSCII).
      Parameter:
      command - basic command after reset
    • time

      public final double time()
      What is the current playing time in secs?
      Gibt zurück:
      the current playing time in secs
    • getPlayList

      public final PlayList getPlayList()
      Get the current playlist.
      Gibt zurück:
      current tune-based playlist
    • getTimer

      public final Timer getTimer()
      Get the current timer.
      Gibt zurück:
      song length timer
    • getTune

      public final SidTune getTune()
      Get the currently played tune.
      Gibt zurück:
      the currently played tune
    • setTune

      public final void setTune(SidTune tune)
      Set a tune to play.
      Parameter:
      tune - tune to play
    • startC64

      public final void startC64()
      Start a player thread.
    • stopC64

      public final void stopC64()
      Stop player thread.
    • stopC64

      public final void stopC64(boolean quitOrWait)
      Stop or wait for player thread.
      Parameter:
      quitOrWait - quit player (true) or wait for termination, only (false)
    • setMenuHook

      public final void setMenuHook(Consumer<Player> menuHook)
      Set a hook to be called when the player has opened a tune.
      Parameter:
      menuHook - menu hook
    • setInteractivityHook

      public final void setInteractivityHook(Consumer<Player> interactivityHook)
      Set a hook to be called when the player has played a chunk.
      Parameter:
      interactivityHook - interactivity hook
    • getWhatsSidHook

      public Consumer<MusicInfoWithConfidenceBean> getWhatsSidHook()
      Get a hook to be called when WhatsSid has detected a tune.
      Gibt zurück:
      hook to be called when WhatsSid has detected a tune
    • setWhatsSidHook

      public void setWhatsSidHook(Consumer<MusicInfoWithConfidenceBean> whatsSidHook)
      Set a hook to be called when WhatsSid has detected a tune.
      Parameter:
      whatsSidHook - hook to be called when WhatsSid has detected a tune
    • setPlayAddrHook

      public void setPlayAddrHook(Function<Integer,Integer> playAddrHook)
      Set a hook to be called when the player address has been read from the tune.
      Parameter:
      playAddrHook - player address hook
    • stateProperty

      public final ObjectProperty<State> stateProperty()
      Get the player's state.
      Gibt zurück:
      the player's state
    • open

      Open player.

      Note: Audio driver different to Audio members are on hold!

      Löst aus:
      LineUnavailableException - audio line currently in use
      IOException - audio output file cannot be written
      InterruptedException - thread interrupted
    • createSIDBuilder

      private SIDBuilder createSIDBuilder(CPUClock cpuClock)
      Create a configured SID chip implementation (software/hardware).
      Parameter:
      cpuClock - CPU clock frequency
      Gibt zurück:
      SID builder
    • getSidBuilder

      public SIDBuilder getSidBuilder()
    • verifyConfiguration

      private void verifyConfiguration()
      Check the configuration.
    • getAudio

      public Audio getAudio()
      Get Audio of an audio driver or null for custom audio drivers.
      Gibt zurück:
      audio audio
    • getAudioDriver

      public AudioDriver getAudioDriver()
      Get currently used audio driver.
      Gibt zurück:
      currently used audio driver
    • setAudioDriver

      public final void setAudioDriver(AudioDriver audioDriver)
      Set alternative audio driver (not contained in Audio).
      For example, If it is required to use a new instance of an audio driver each time the player plays a tune (e.g. MP3Driver.MP3StreamDriver)
      Parameter:
      audioDriver - for example MP3Driver.MP3StreamDriver
    • setAudioAndDriver

      private void setAudioAndDriver(Audio audio, AudioDriver audioDriver)
      Set audio for the play-back
      Parameter:
      audio - audio for play-back
    • setUncaughtExceptionHandler

      public void setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler uncaughtExceptionHandler)
      Set an uncaught Player exception handler.
      Parameter:
      uncaughtExceptionHandler - excdeption handler
    • setCheckDefaultLengthInRecordMode

      public void setCheckDefaultLengthInRecordMode(boolean checkDefaultLengthInRecordMode)
      Set check default length in record mode (default is true).
      Parameter:
      checkDefaultLengthInRecordMode - check the default length in record mode
    • setCheckLoopOffInRecordMode

      public void setCheckLoopOffInRecordMode(boolean checkLoopOffInRecordMode)
      Set the check loop off in record mode (default is true).
      Parameter:
      checkLoopOffInRecordMode - check loop off in record mode
    • setForceCheckSongLength

      public void setForceCheckSongLength(boolean forceCheckSongLength)
      Set force check song length (default is false).
      Parameter:
      forceCheckSongLength - force check song length
    • setFirstPlayListEntryIsOne

      public void setFirstPlayListEntryIsOne(boolean firstPlayListEntryIsOne)
      Set first entry of the playlist is the first song (otherwise start song).
      Parameter:
      firstPlayListEntryIsOne - The first entry of the playlist is the first song (otherwise start song)
    • play

      private boolean play() throws InterruptedException
      Play routine (clock chips until the audio buffer is filled or the player gets paused).
      Gibt zurück:
      continue to play next time?
      Löst aus:
      InterruptedException - audio production interrupted
    • close

      private void close()
      Close player.
    • play

      public final void play(SidTune tune)
      Play tune.
      Parameter:
      tune - tune to play (RESET means reset C64)
    • resetC64

      public final void resetC64(String command)
      Reset C64 and enter a basic command.
      Parameter:
      command - basic command to be entered after a normal reset
    • play

      private void play(SidTune tune, String command)
      Turn C64 off and on, load a tune, and enter a basic command.
      Parameter:
      tune - tune to play (RESET means reset C64)
      command - basic command to be entered after a normal reset
    • pauseContinue

      public final void pauseContinue()
      Pause or continue the player.
    • nextSong

      public final void nextSong()
      Play the next song.
    • previousSong

      public final void previousSong()
      Play previous song.
      Note: After PREV_SONG_TIMEOUT has been reached, the current tune is restarted instead.
    • firstSong

      public final void firstSong()
      Play first song.
    • lastSong

      public final void lastSong()
      Play last song.
    • getMixerInfo

      public final <T> T getMixerInfo(Function<Mixer,T> function, T defaultValue)
      Get mixer info.
      Parameter:
      function - mixer function to apply
      defaultValue - default value, if SIDBuilder does not implement a mixer
      Gibt zurück:
      mixer info
    • quit

      public final void quit()
      Quit player.
    • setSidDatabase

      public final void setSidDatabase(SidDatabase sidDatabase)
      Set a song length database.
      Parameter:
      sidDatabase - song length database
    • getSidDatabaseInfo

      public final <T> T getSidDatabaseInfo(Function<SidDatabase,T> function, T defaultValue)
      Get song length database info.
      Typparameter:
      T - SidDatabase return type
      Parameter:
      function - SidDatabase function to apply
      defaultValue - default value, if a database is not set
      Gibt zurück:
      song length database info
    • setSTIL

      public final void setSTIL(STIL stil)
      Set SID Tune Information List (STIL).
      Parameter:
      stil - SID Tune Information List
    • getStilEntry

      public final STIL.STILEntry getStilEntry(String collectionName)
      Get SID Tune Information List info.
      Parameter:
      collectionName - entry path to get infos for
      Gibt zurück:
      SID Tune Information List info
    • getRecordingFilename

      public String getRecordingFilename()
      Get the recording filename, add audio related file extension (if known).
      Gibt zurück:
      recording filename
    • setRecordingFilenameProvider

      public final void setRecordingFilenameProvider(Function<SidTune,String> recordingFilenameProvider)
      Set the provider of recording filenames.
      Parameter:
      recordingFilenameProvider - provider of recording filenames
    • addVideoDriver

      public void addVideoDriver(VideoDriver consumer)
      Add consumer of VIC screen output as ARGB data
      Parameter:
      consumer - consumer of C64 screen pixels as ARGB data
    • removeVideoDriver

      public void removeVideoDriver(VideoDriver consumer)
      Remove consumer of VIC screen output as ARGB data
      Parameter:
      consumer - consumer of C64 screen pixels as ARGB data
    • addSidListener

      public void addSidListener(SIDListener consumer)
      Add consumer of SID register writes
      Parameter:
      consumer - consumer of SID register writes
    • removeSidListener

      public void removeSidListener(SIDListener consumer)
      Remove consumer of SID register writes
      Parameter:
      consumer - consumer of SID register writes
    • addMOS6510Extension

      public void addMOS6510Extension(IMOS6510Extension mos6510Extension)
      Add consumer of MOS6510 JMP/JSR instructions.
      Parameter:
      mos6510Extension - consumer of MOS6510 JMP/JSR instructions
    • removeMOS6510Extension

      public void removeMOS6510Extension(IMOS6510Extension mos6510Extension)
      Remove consumer of MOS6510 JMP/JSR instructions.
      Parameter:
      mos6510Extension - of MOS6510 JMP/JSR instructions
    • accept

      public void accept(VIC vic)
      Fast-forward skips frames and produces output for each Xth frame (X = 1x, 2x, 4x, ... , 32x).
      Angegeben von:
      accept in Schnittstelle Consumer<VIC>
      Angegeben von:
      accept in Schnittstelle VideoDriver
    • write

      public void write(int sidNum, int addr, byte data)
      Angegeben von:
      write in Schnittstelle SIDListener
    • jmpJsr

      public void jmpJsr()
      Angegeben von:
      jmpJsr in Schnittstelle IMOS6510Extension
    • getAutodetection

      public Autodetection getAutodetection()
    • getCredits

      public final String getCredits(String version)
      The credits for the authors of many parts of this emulator.
      Parameter:
      version - containing the version of JSIDPlay2
      Gibt zurück:
      the credits
    • main

      public static void main(String[] args) throws IOException, SidTuneError
      Test main: Play a tune.
      Parameter:
      args - the filename of the tune is the first arg
      Löst aus:
      SidTuneError - SID tune error
      IOException - tune file cannot be read