Notica
一个 Fabric 模组,用于在服务器上向玩家播放 .nbs 文件格式的音符盒歌曲。
此模组在服务端兼容原版,这意味着未安装此模组的原版玩家也可以加入服务器。
安装了此模组的玩家将受益于更低的网络流量以及更好的播放质量。
演示
功能
NBS 文件播放
在服务器或单人游戏中播放由 Open Note Block Studio 创建的任何歌曲。
将 .nbs 文件放入 config/notica/songs 目录中。
使用 /music play <song> for [players] 命令来播放歌曲。
注意:此模组不包含任何歌曲文件,你需要自行下载。
你可以在 Noteblock World 找到许多 NBS 歌曲。
客户端歌曲播放
在原版客户端连接中,每个音符都通过单独的数据包发送给玩家。
这会产生大量发送的数据包,从而导致延迟和播放质量下降。
然而,如果玩家安装了此模组,歌曲音符会被打包成块并以较大但数量少得多的数据包发送。
此过程类似于视频缓冲。
改进的播放质量
原版 Minecraft 存在一些限制,会影响歌曲的播放质量。
首先,音符只能在特定的八度音程范围内播放(F#3 到 F#5)。
其次,声音在世界中必须具有整数位置,这会在玩家播放期间移动时导致音频伪影。
此外,由于音符位置被钳制到最近的整数值,立体声声像定位显著变差。
安装了 Notica 的客户端不受这些限制,因为音符是通过 Minecraft: Java Edition 使用的音频引擎 OpenAL 直接播放的。
因此,歌曲播放的效果将与 Open Note Block Studio 内的播放效果相似。
自定义乐器
任何 Minecraft 声音都可以用作 .nbs 文件中的自定义乐器。
Notica 支持 nbs 文件格式规范(最高至版本 5)的所有自定义乐器相关功能。
任意歌曲速度
与其他服务端 nbs 播放器一样,Notica 不受特定歌曲速度的限制。
此模组通过异步运行歌曲播放来确保播放时间准确。
数据包在不进行服务器线程同步的情况下发送,否则会将速度再次限制为每秒 20 刻。
歌曲循环
NBS 格式版本 4 引入了循环选项,如开/关、最大循环次数和循环起始刻。
此模组支持这些选项并会相应地自动循环。
提示:如果歌曲无限循环,你可以使用游戏内的 /music stop 命令停止它。
扩展八度范围
如前所述,Minecraft 对音符音高施加了限制,将八度范围限制在 F#3 到 F#5。
模组玩家没有此限制,但原版玩家仍受影响。
超出原版范围的音符默认会为原版玩家进行移调,以便可以播放。
原版客户端仍然可以通过安装扩展音符资源包来播放超出原版范围的音符。
可以使用 /music set extended_range true 启用扩展范围播放来安装额外的音符资源包(仅限原版玩家)。
位置音乐播放
歌曲可以通过世界中的“扬声器”播放。
扬声器可以具有固定位置,也可以附加到实体上。
如果扬声器的实体移动,歌曲也会随之移动。
多普勒效应
附加到实体的歌曲可以启用多普勒效应,根据实体相对于玩家的运动来扭曲音频音高。
在模组设置中,这可以扩展为也使用玩家的运动。
这将使用 OpenAL 启用完整的多普勒效应模拟。
命令
所有 /music 命令都需要 OP 权限或上面表格中列出的相应权限。
播放
为自己播放一首歌曲:
/music play <song>
为特定玩家或所有在线玩家播放一首歌曲:
/music play MySong.nbs for @a
/music play MySong.nbs global
<song> 参数是相对于 config/notica/songs 目录的 .nbs 文件路径。Tab 补全将建议可用文件。
以 global 开头的歌曲也会在歌曲播放期间加入服务器的玩家自动播放。
音量和播放选项
在监听者参数后指定 0.0 到 1.0 之间的音量:
/music play MySong.nbs for @a 0.7
有两种播放变体可用:individual(独立)和 streamed(流式)。默认使用 streamed。
使用 individual 播放时,每个音符都直接通过 Minecraft 的声音系统播放,该系统同时播放声音的限制为 256 个。此池与所有其他游戏声音共享。当池满时,音符数高的歌曲可能会丢弃某些音符,并且其他游戏声音也可能在这种情况下被切断。
使用 streamed 播放时,自定义音频混音器会从所有音符生成单个音频流。这可以处理任何同时音符数的歌曲,同时保持高音质,且不干扰其他游戏声音。与 streamed 相比,具有大量立体声声像的歌曲在 individual 播放下听起来可能略有不同。
/music play MySong.nbs for @a 0.8 individual
/music play MySong.nbs for @a 0.8 streamed
流式播放还支持两种立体声混合模式,spatial(空间,默认)和 equal_power(等功率):
/music play MySong.nbs for @a 0.8 streamed equal_power
歌曲 ID
每首活跃的歌曲都有一个 ID。如果没有给出显式 ID,则 ID 源自文件名和运行命令的玩家名称。以这种方式启动歌曲会自动停止已受影响的监听者正在播放的任何歌曲。
若要同时播放多首歌曲,请使用 id 关键字提供显式 ID。这也会跳过自动停止:
/music play Ambient.nbs for @a 0.5 individual id myserver:ambient
/music play Theme.nbs for @a 0.8 id myserver:theme
ID 也用于 /music stop 和 /music seek 以定位特定歌曲。
位置播放
可以通过世界中的固定位置的扬声器播放歌曲,或将其附加到移动实体上:
/music play MySong.nbs at position 100 64 200
/music play MySong.nbs at position 100 64 200 for @a
/music play MySong.nbs at entity @e[type=armor_stand,limit=1]
/music play MySong.nbs at entity @e[type=armor_stand,limit=1] for @a
在音量之后,您可以配置扬声器范围和半径。range(16 到 128)是可以听到歌曲的最大距离(以方块为单位)。radius(0 到 15)适用于立体声歌曲,并确定左声道和右声道扬声器在世界中放置的距离:
/music play MySong.nbs at position 0 64 0 for @a 0.8 64 8
使用单声道模式会将歌曲混音为单个点状源。这使得扬声器表现得像空间中的一个单点,而不是分散的立体声对。请注意,混音会使声音稍微变小。必须启用单声道才能为实体扬声器启用多普勒效应:
/music play MySong.nbs at position 0 64 0 for @a 0.8 streamed mono
多普勒效应
支持流式传输的单声道实体扬声器支持多普勒效应,该效应会根据实体相对于每个听众的速度改变音调。这需要客户端安装 Notica:
/music play MySong.nbs at entity @e[type=minecart,limit=1] for @a 0.8 streamed mono doppler
停止
停止您当前正在播放的所有歌曲:
/music stop
停止特定玩家的歌曲、服务器上的所有歌曲或通过 ID 停止特定歌曲:
/music stop for <players>
/music stop all
/music stop id <id>
/music stop for <players> <id>
以 global 开始的歌曲只能使用 /music stop id 或 /music stop all 停止。
添加听众
将玩家添加到已经播放的歌曲中,而无需重新启动它:
/music add <id> <players>
搜索
使用 s/sec 表示秒,m/min 表示分钟,或 t/ticks 表示刻,跳转到歌曲中的特定位置。纯数字会跳转到绝对位置;带有 + 或 - 前缀的数字会相对于当前位置跳转:
/music seek 1m30s
/music seek +10s
/music seek -30t
/music seek 50sec+3ticks
要为特定玩家或特定歌曲进行搜索:
/music seek +10s <players>
/music seek +10s <players> <id>
客户端设置
这些命令对所有玩家可用,不需要任何权限。
设置您的个人播放音量(0 到 100 百分比):
/music set volume 75
启用扩展八度范围资源包(仅限原版玩家,参见 Extended octave range):
/music set extended_range true
权限
为了播放或停止音乐,您需要是服务器操作员(拥有 OP),或者需要相应的权限:
| 操作 |
所需权限 |
| 播放音乐 |
notica.command.music.play |
| 播放位置歌曲 |
notica.command.music.play.positional |
| 向他人播放音乐 |
notica.command.music.play.other |
| 停止音乐 |
notica.command.music.stop |
| 为他人停止音乐 |
notica.command.music.stop.other |
| 搜索音乐 |
notica.command.music.seek |
| 为他人搜索音乐 |
notica.command.music.seek.other |
类似项目
开发者 API
Notica 为开发者提供了 API,以便其他模组可以使用 Notica 的功能。
API 文档可以在 GitHub 上找到。
Notica
A Fabric mod for playing note block songs in the .nbs file format to your players.
This mod is vanilla compatible on the server-side, which means that vanilla players can join without this mod installed as well.
Players with the mod installed benefit from reduced network-usage, as well as better playback quality.
Demo
Features
NBS file playback
Play any song created with Open Note Block Studio on a server or in single player.
Place the .nbs files in the config/notica/songs directory.
Use the /music play <song> for [players] command to play a song.
Note: This mod does not include any song files, you need download them yourself.
You can find many NBS songs at Noteblock World.
Clientside song playback
On a vanilla client connection, each note is sent to the player with a separate packet.
This creates huge amounts of packets being sent, which causes lag and reduced playback quality.
However, if a player has the mod installed, the song notes are packed into chunks and sent in larger, but way less packets.
This process is similar to video buffering.
Improved playback quality
Vanilla Minecraft has some limitations that impact the playback quality of songs.
For one, notes can only be played in a certain octave range (F#3 to F#5).
For another, sounds must have an integer position in the world, which causes audio artifacts when the player is moving during playback.
Additionally, stereo panning of notes is significantly worse because note positions are clamped to the nearest integer values.
Clients with Notica installed do not have these limitations, as notes are played directly via OpenAL, the audio engine used by Minecraft: Java Edition.
Song playback will thereby sound similar to the playback within Open Note Block Studio.
Custom instruments
Any Minecraft sound can be used as a custom instrument in .nbs files.
Notica supports all custom instrument related features of the nbs file format specification (up to version 5).
Arbitrary song tempo
Much like other server-sided nbs players, Notica is not limited to specific song tempos.
This mod makes sure that the song playback timings are accurate, by running song playbacks asynchronously.
Packets are sent without server-thread synchronization, which would limit the tempo to 20 ticks per second again.
Song Looping
NBS format version 4 introduces loop-options like on/off, max loop count and loop start tick.
This mod supports these options and will automatically loop accordingly.
Hint: If a song loops indefinitely, you can stop it using /music stop in-game.
Extended octave range
As mentioned earlier, Minecraft imposes a limit to the note pitch, limiting the octave range to F#3 until F#5.
Modded players do not have this limitation, but vanilla players are still impacted.
Notes outside the vanilla range will be transposed for vanilla players by default, so that can be played.
Vanilla clients are still able to play notes outside the vanilla range, by installing the extended notes resource pack.
The extra notes resource pack can be installed by using /music set extended_range true to enable the extended range playback (vanilla players only).
Positional music playing
Songs can be played through "speakers" at positions in the world.
A speaker may either have a fixed position or may be attached to an entity.
If the entity of a speaker moves, the song moves as well.
Doppler effect
Songs attached to entities may enable the doppler effect which distorts the audio pitch depending on the entity motion relative to the player.
In the mod settings this may be extended to use the player's motion as well.
This will enable a complete doppler effect simulation using OpenAL.
Commands
All /music commands require OP or the corresponding permission listed in the table above.
Playing
Play a song for yourself:
/music play <song>
Play a song for specific players or all online players:
/music play MySong.nbs for @a
/music play MySong.nbs global
The <song> argument is the path to a .nbs file relative to the config/notica/songs directory. Tab-completion will suggest available files.
Songs started with global are also automatically played for players who join the server while the song is running.
Volume and playback options
Specify a volume between 0.0 and 1.0 after the listener argument:
/music play MySong.nbs for @a 0.7
Two playback variants are available: individual and streamed. streamed is used by default.
With individual playback, each note is played directly through Minecraft's sound system, which has a limit of 256 simultaneously playing sounds. This pool is shared with all other game sounds. Songs with a high simultaneous note count may have notes dropped when the pool is full, and other game sounds may also be cut off in that case.
With streamed playback, a custom audio mixer produces a single audio stream from all notes. This handles songs with any simultaneous note count while maintaining high sound quality, and does not interfere with other game sounds. Songs with a lot of stereo panning may sound slightly different under individual playback compared to streamed.
/music play MySong.nbs for @a 0.8 individual
/music play MySong.nbs for @a 0.8 streamed
Streamed playback also supports two stereo mixing modes, spatial (default) and equal_power:
/music play MySong.nbs for @a 0.8 streamed equal_power
Song IDs
Every active song has an ID. When no explicit ID is given, the ID is derived from the filename and the name of the player who ran the command. Starting a song this way automatically stops any songs already playing for the affected listeners.
To play multiple songs at the same time, provide an explicit ID using the id keyword. This also skips the auto-stop:
/music play Ambient.nbs for @a 0.5 individual id myserver:ambient
/music play Theme.nbs for @a 0.8 id myserver:theme
The ID is also used with /music stop and /music seek to target a specific song.
Positional playback
Songs can be played through a speaker at a fixed position in the world or attached to a moving entity:
/music play MySong.nbs at position 100 64 200
/music play MySong.nbs at position 100 64 200 for @a
/music play MySong.nbs at entity @e[type=armor_stand,limit=1]
/music play MySong.nbs at entity @e[type=armor_stand,limit=1] for @a
After the volume you can configure the speaker range and radius. range (16 to 128) is the maximum distance in blocks at which the song can be heard. radius (0 to 15) applies to stereo songs and determines how far apart the left and right speaker channels are placed in the world:
/music play MySong.nbs at position 0 64 0 for @a 0.8 64 8
Using mono channel mode down-mixes the song to a single point-like source. This makes the speaker behave like a single point in space rather than a spread stereo pair. Note that down-mixing will make the sound a bit quieter. Mono is required to enable the doppler effect on entity speakers:
/music play MySong.nbs at position 0 64 0 for @a 0.8 streamed mono
Doppler effect
Entity speakers with mono streamed playback support the doppler effect, which shifts the pitch based on the entity's velocity relative to each listener. This requires Notica to be installed on the client:
/music play MySong.nbs at entity @e[type=minecart,limit=1] for @a 0.8 streamed mono doppler
Stopping
Stop all songs currently playing for yourself:
/music stop
Stop songs for specific players, all songs on the server, or a specific song by ID:
/music stop for <players>
/music stop all
/music stop id <id>
/music stop for <players> <id>
Songs started with global can only be stopped with /music stop id or /music stop all.
Adding listeners
Add players to a song that is already playing without restarting it:
/music add <id> <players>
Seeking
Jump to a specific position in a song using s/sec for seconds, m/min for minutes, or t/ticks for ticks. A plain number seeks to an absolute position; a + or - prefix seeks relative to the current position:
/music seek 1m30s
/music seek +10s
/music seek -30t
/music seek 50sec+3ticks
To seek for specific players or a specific song:
/music seek +10s <players>
/music seek +10s <players> <id>
Client settings
These commands are available to all players and do not require any permissions.
Set your personal playback volume (0 to 100 percent):
/music set volume 75
Enable the extended octave range resource pack (vanilla players only, see Extended octave range):
/music set extended_range true
Permissions
In order to play or stop music, you need to be a server operator (have OP) or you need to have the corresponding permissions:
| Action |
Required permission |
| Play music |
notica.command.music.play |
| Play positional songs |
notica.command.music.play.positional |
| Play music to others |
notica.command.music.play.other |
| Stop music |
notica.command.music.stop |
| Stop music for others |
notica.command.music.stop.other |
| Seek music |
notica.command.music.seek |
| Seek music for others |
notica.command.music.seek.other |
Similar projects
Developer API
Notica provides an API for developers so that other mods can use features from Notica.
The API documentation can be found on GitHub.
评论 0
登录后参与评分
还没有评论,来抢沙发吧