Show / Hide Table of Contents

Class MusicBank

The persistent storage for playlists and music players.

Inheritance
System.Object
MusicBank
Implements
IBank
ISerializationCallbackReceiver
Namespace: Stem
Assembly: Stem.dll
Syntax
public class MusicBank : ScriptableObject, IBank, ISerializationCallbackReceiver

Properties

| Improve this Doc View Source

Players

The collection of music players.

Declaration
public ReadOnlyCollection<MusicPlayer> Players { get; }
Property Value
Type Description
System.Collections.ObjectModel.ReadOnlyCollection<MusicPlayer>

A reference to a read-only collection of music players.

| Improve this Doc View Source

PlaylistBatchImportMode

The batch import mode defining how new playlists will be created after the drag-drop event.

Declaration
public AudioClipImportMode PlaylistBatchImportMode { get; set; }
Property Value
Type Description
AudioClipImportMode

An enum value.

| Improve this Doc View Source

PlaylistManagementMode

The default audio clip management mode for all playlists of the music bank.

Declaration
public AudioClipManagementMode PlaylistManagementMode { get; set; }
Property Value
Type Description
AudioClipManagementMode

An enum value.

Remarks

By default, all playlists will use this value for audio clip management, however, it can be overridden by the OverrideAudioClipManagement flag.

| Improve this Doc View Source

Playlists

The collection of playlists.

Declaration
public ReadOnlyCollection<Playlist> Playlists { get; }
Property Value
Type Description
System.Collections.ObjectModel.ReadOnlyCollection<Playlist>

A reference to a read-only collection of playlists.

| Improve this Doc View Source

PlaylistUnloadInterval

The default audio clip unload interval for all playlists of the the music bank.

Declaration
public float PlaylistUnloadInterval { get; set; }
Property Value
Type Description
System.Single

A time interval in seconds.

Remarks

By default, all playlists will use this value for audio clip unload interval, however, it can be overridden by the OverrideAudioClipManagement flag.

| Improve this Doc View Source

ShowPlayers

The flag indicating whether the music bank inspector should show the 'Players' group.

Declaration
public bool ShowPlayers { get; set; }
Property Value
Type Description
System.Boolean

True, if the 'Players' group is shown. False otherwise.

Remarks

This property is used only by the music bank inspector and does nothing during runtime.

| Improve this Doc View Source

ShowPlaylists

The flag indicating whether the music bank inspector should show the 'Playlists' group.

Declaration
public bool ShowPlaylists { get; set; }
Property Value
Type Description
System.Boolean

True, if the 'Playlists' group is shown. False otherwise.

Remarks

This property is used only by the music bank inspector and does nothing during runtime.

Methods

| Improve this Doc View Source

AddMusicPlayer(String)

Adds a new music player to the music bank.

Declaration
public MusicPlayer AddMusicPlayer(string name)
Parameters
Type Name Description
System.String name

Name of the music player.

Returns
Type Description
MusicPlayer

A reference to a newly created music player.

| Improve this Doc View Source

AddPlaylist(String)

Adds an empty playlist to the music bank.

Declaration
public Playlist AddPlaylist(string name)
Parameters
Type Name Description
System.String name

Name of the playlist.

Returns
Type Description
Playlist

A reference to a newly created playlist.

| Improve this Doc View Source

AddPlaylist(String, AudioClip)

Adds a new playlist with a single track to the music bank.

Declaration
public Playlist AddPlaylist(string name, AudioClip clip)
Parameters
Type Name Description
System.String name

Name of the playlist.

AudioClip clip

A reference to the audio clip with music data.

Returns
Type Description
Playlist

A reference to a newly created playlist.

| Improve this Doc View Source

AddPlaylist(String, AudioClip[])

Adds a new playlist with multiple tracks to the music bank.

Declaration
public Playlist AddPlaylist(string name, AudioClip[] clips)
Parameters
Type Name Description
System.String name

Name of the playlist.

AudioClip[] clips

An array of audio clips with music data.

Returns
Type Description
Playlist

A reference to a newly created playlist.

| Improve this Doc View Source

GetBankID()

Returns music bank ID.

Declaration
public ID GetBankID()
Returns
Type Description
ID

An ID value.

| Improve this Doc View Source

GetMusicPlayer(ID)

Searches for the specified music player by ID.

Declaration
public MusicPlayer GetMusicPlayer(ID id)
Parameters
Type Name Description
ID id

ID that refers to a music player.

Returns
Type Description
MusicPlayer

A reference to a music player, if found. Null reference otherwise.

| Improve this Doc View Source

GetMusicPlayer(String)

Searches for the specified music player with a matching name.

Declaration
public MusicPlayer GetMusicPlayer(string name)
Parameters
Type Name Description
System.String name

Name of the music player.

Returns
Type Description
MusicPlayer

A reference to a music player, if found. Null reference otherwise.

| Improve this Doc View Source

GetMusicPlayerID(Int32)

Gets an ID to the specific music player.

Declaration
public ID GetMusicPlayerID(int index)
Parameters
Type Name Description
System.Int32 index

Zero-based index of the music player in the current music bank.

Returns
Type Description
ID

An ID to the specific music player.

| Improve this Doc View Source

GetPlaylist(ID)

Searches for the specified playlist by ID.

Declaration
public Playlist GetPlaylist(ID id)
Parameters
Type Name Description
ID id

ID that refers to a playlist.

Returns
Type Description
Playlist

A reference to a playlist, if found. Null reference otherwise.

| Improve this Doc View Source

GetPlaylist(String)

Searches for the specified playlist with a matching name.

Declaration
public Playlist GetPlaylist(string name)
Parameters
Type Name Description
System.String name

Name of the playlist.

Returns
Type Description
Playlist

A reference to a playlist, if found. Null reference otherwise.

| Improve this Doc View Source

GetPlaylistID(Int32)

Gets an ID to the specific playlist.

Declaration
public ID GetPlaylistID(int index)
Parameters
Type Name Description
System.Int32 index

Zero-based index of the playlist in the current music bank.

Returns
Type Description
ID

An ID to the specific playlist.

| Improve this Doc View Source

OnAfterDeserialize()

Prepares music bank for runtime use after deserialization.

Declaration
public void OnAfterDeserialize()
Remarks

This method is automatically called by Unity during deserialization process. Don't call it manually.

| Improve this Doc View Source

OnBeforeSerialize()

Prepares music bank for serialization.

Declaration
public void OnBeforeSerialize()
Remarks

This method is automatically called by Unity during serialization process. Don't call it manually.

| Improve this Doc View Source

RegenerateBankID()

Generates a new unique ID for the music bank.

Declaration
public void RegenerateBankID()
Remarks

This method is automatically called by Stem during serialization process. Don't call it manually as it may break existing ID references.

| Improve this Doc View Source

RemoveMusicPlayer(MusicPlayer)

Removes existing music player from the music bank.

Declaration
public void RemoveMusicPlayer(MusicPlayer player)
Parameters
Type Name Description
MusicPlayer player

A reference to a music player.

Remarks

This method does nothing if the music player was not found in the music bank.

| Improve this Doc View Source

RemovePlaylist(Playlist)

Removes existing playlist from the music bank.

Declaration
public void RemovePlaylist(Playlist playlist)
Parameters
Type Name Description
Playlist playlist

A reference to a playlist.

Remarks

This method does nothing if the playlist was not found in the music bank.

All existing music players containing removed playlist will set their playlist reference to null.

Events

| Improve this Doc View Source

OnMusicPlayerAdded

The delegate informing about adding music players.

Declaration
public event MusicPlayerAddedDelegate OnMusicPlayerAdded
Event Type
Type Description
MusicPlayerAddedDelegate
| Improve this Doc View Source

OnMusicPlayerRemoved

The delegate informing about removing music players.

Declaration
public event MusicPlayerRemovedDelegate OnMusicPlayerRemoved
Event Type
Type Description
MusicPlayerRemovedDelegate
| Improve this Doc View Source

OnMusicPlayerRenamed

The delegate informing about the change of music player names.

Declaration
public event MusicPlayerRenamedDelegate OnMusicPlayerRenamed
Event Type
Type Description
MusicPlayerRenamedDelegate
| Improve this Doc View Source

OnPlaylistAdded

The delegate informing about adding playlists.

Declaration
public event PlaylistAddedDelegate OnPlaylistAdded
Event Type
Type Description
PlaylistAddedDelegate
| Improve this Doc View Source

OnPlaylistRemoved

The delegate informing about removing playlists.

Declaration
public event PlaylistRemovedDelegate OnPlaylistRemoved
Event Type
Type Description
PlaylistRemovedDelegate
| Improve this Doc View Source

OnPlaylistRenamed

The delegate informing about the change of playlist names.

Declaration
public event PlaylistRenamedDelegate OnPlaylistRenamed
Event Type
Type Description
PlaylistRenamedDelegate

Implements

IBank
ISerializationCallbackReceiver
  • Improve this Doc
  • View Source
Back to top Generated by DocFX