Classes (extension) | UGens > InOut | UGens > Buffer

SFPlayer : Object

A soundfile player
Source: SFPlayer.sc


SFPlayer plays sound files directly from disk. It also has a convenient -gui.

The most common use is: SFPlayer.new.gui or SFPlayer.new("/path/to/soundfile").gui. See examples below.

Class Methods

SFPlayer.new(path, outbus, server, skin, autoShowOpenDialog: true, autoBootServer: true, autoSetSampleRate: true, autoSetOutputChannels: true)



The path to a soundfile. Can be nil for choosing the file later.


The bus to output to. Defaults to 0 (the first physical output).


The server to use. If nil, Server.default will be used.


Optionally an instance of SFPlayerSkin, controlling the color scheme of the GUI when shown.


If true and no path is specified, an Open Dialog will be shown upon creating new instance to choose the file.


If true and the server is not running, it will be booted automatically.


If true and the server is booted automatically, its sampleRate will be set to the file's sampleRate.


If true and the number of channels in the file exceeds server's number of output channels, as well as the server is booted automatically, its number of output channels will be increased to match the number of channels in the soundfile.

Inherited class methods

Instance Methods

.gui(argBounds, doneAction, onCloseAction, parent)

Show a GUI of the SFPlayer. This creates an instance of SFPlayerView, stored under -view.



Bounds of the gui. If nil, a default size will be used.


Action to be performed after opening the gui and loading the soundfile into the SoundFileView.


Action to be performed after closing the gui.


Optionally a parent view to embed this SFPlayerView in.


this SFPlayer (not the SFPlayerView)

.play(bufsize, addAction, target, rate)

Play the file from the current position;

.stop(updateStart: true)

Stop playing. startTime is left at the original value;



If true, the cursor in the GUI and other dependants will be reset to the previous start postion.


Stop playing. startTime is updated to the current playback position.

NOTE: If pause is called when the player is stopped, it will preload the playback buffer and wait for the start of playback. This allows starting playback without additional delay on slower storage or when multiple players are synchronized together


Updates the player to the initial state (resets playback position, amp, etc.)



If the gui was created, this returns an instance of the SFPlayerView.


.attRelTime = val

Get/Set the time of fade in / fade out when starting/stopping. Increase this value for seamless looping (see below).


NOTE: For seamless looping, increase attRelTime and set the loopEnd parameter to at least attRelTime less than the soundfile's duration.


.loop = val

Turn looping on/off by setting loop to true or false.


.loopBeginning = val

Get/Set loop beginning (in seconds).


.loopEnd = val

Get/Set loop end (in seconds).

.loopBeginningEnd_(beginning, end)

Set both beginning and end of the loop (used by the SFPlayerView).

Synchronizing multiple players

It is possible to link multiple players together and have them start playback at the same time.

Inherited instance methods

Undocumented instance methods


.addAction = val

.addCue(key, time, sort: true, redraw: true)


.amp_(newAmp, source)


.autoBootServer = value


.autoSetOutputChannels = value


.autoSetSampleRate = value





.bufsize = val







.defaultOpenPath = value


.duplicateSingleChannel = value


.followAddAction = value


.followAmp = value


.followLoop = value


.followOutbus = value


.followPlayStopPause = value


.followRate = value


.followStartTime = value


.followTarget = value









.loadBuffer(sTime: 0, completionMessage)



.multiplyBufsizeByNumChannels = value

.offset = newOffset


.outbus_(newOut, updateMenu: true)


.path = pathArg


.playFromCue(key, idx)



.rate = val

.removeCue(key, sort: true, redraw: true)




.setCues(newCues, forSure: false)





.startTime = newStartTime


.switchTargetWhilePlaying = value



.target = val

.update(who, what ... args)