7lab_groove_test 中文文档教程

发布于 7年前 浏览 28 项目主页 更新于 3年前

node-groove

Node.js 绑定到 libgroove - 通用音乐播放器后端库。

freenode 上的 #libgroove 中进行现场讨论。

以下是主要界面。 有关详细信息,请参阅下面的 API 文档。

  • GrooveFile - represents an open audio file.
  • GroovePlaylist - put files in the playlist, and the playlist decodes the files and fills up the attached sinks.
  • GroovePlayer - attach this sink to a playlist to play the decoded audio over the system's speakers.
  • GrooveEncoder - attach this sink to a playlist to obtain encoded audio buffers, such as an mp3 stream.
  • GrooveLoudnessDetector - attach this sink to a playlist to compute how loud files sound to the human ear, along with the "true peak" value. You can use this to implement ReplayGain.
  • GrooveFingerprinter - attach this sink to a playlist to compute an acoustid fingerprint. This can be used to look up a file by its audio content and figure out which tags should be applied.
  • GrooveWaveformBuilder - attach this sink to a playlist to compute a JSON representation of an audio file. This can be used to display a visualization of the audio file.

Usage

  1. Install libgroove to your system. libgroove is a set of 4 libraries; node-groove depends on all of them. So for example on ubuntu, make sure to install libgroove-dev, libgrooveplayer-dev, libgrooveloudness-dev, and libgroovefingerprinter-dev.
  2. npm install --save groove

Versions

  • node-groove >=3.0.0 depends on libgroove >=5.0.0
  • node-groove >=2.4.0 <3.0.0 depends on libgroove >=4.3.0 <5.0.0
  • node-groove 2.3.4 depends on libgroove <4.3.0

有关发行说明和升级指南,请参阅 CHANGELOG.md。

Get Metadata from File

var groove = require('groove');

groove.open("danse-macabre.ogg", function(err, file) {
  if (err) throw err;
  console.log(file.metadata());
  console.log("duration:", file.duration());
  file.close(function(err) {
    if (err) throw err;
  });
});

More Examples

  • example/metadata.js - read or update metadata in a media file
  • example/playlist.js - play several files in a row and then exit
  • example/replaygain.js - compute replaygain values for media files
  • example/transcode.js - convert and splice several files together
  • example/fingerprint.js - create an acoustid fingerprint for media files
  • example/devices.js - list the playback devices on the system
  • example/waveform.js - calculate a waveformjs compatible representation of a media file

API Documentation

globals

groove.setLogging(level)

level 可以是:

  • groove.LOG_QUIET
  • groove.LOG_ERROR
  • groove.LOG_WARNING
  • groove.LOG_INFO

groove.loudnessToReplayGain(loudness)

将 LUFS 中的响度值转换为 ReplayGain 建议的 dB 调整。

groove.dBToFloat(dB)

将 dB 格式音量调整转换为浮点增益格式。

groove.getVersion()

返回具有以下属性的对象:

  • major
  • minor
  • patch

GrooveFile

groove.open(filename, callback)

callback(err, file)

file.close(callback)

callback(err)

file.duration()

以秒为单位。

file.shortNames()

格式的短名称的逗号分隔列表。

file.getMetadata(key, [flags])

标志:

  • groove.TAG_MATCH_CASE
  • groove.TAG_DONT_OVERWRITE
  • groove.TAG_APPEND

file.setMetadata(key, value, [flags])

有关标志,请参阅 getMetadata

value 传递 null 以删除键。

file.metadata()

这将返回一个填充了所有元数据的对象。 更新对象什么都不做。 使用 setMetadata 来 更新元数据,然后保存将更改写入磁盘。

file.dirty

布尔值 save 是否会做任何事情。

file.filename

传递给 groove.open 的字符串

file.overrideDuration(duration)

如果您确定文件的实际持续时间,请调用此函数 设置文件的实际持续时间(以秒为单位)。 GrooveWaveformBuilder 将使用此值代替 file.duration()

仅当没有 GroovePlaylistItem 引用此文件时才必须调用此方法。

file.save(callback)

callback(err)

GroovePlaylist

groove.createPlaylist()

保持音频缓冲区满的播放列表管理器。 发送缓冲区 到你的扬声器,使用 playlist.createPlayer()

注意:您可能只想要一个播放列表。 在 node-groove 中,播放列表是 低级音频处理概念,不要与面向用户混淆 用户可以在其中添加、删除和重新排序歌曲的播放列表。

playlist.destroy()

完成播放列表后,您必须销毁它。

playlist.items()

返回播放列表项的只读数组。 使用playlist.insertplaylist.remove 进行修改。

[playlistItem1, playlistItem2, ...]

playlist.play()

playlist.pause()

playlist.seek(playlistItem, position)

寻找 playlistItem位置 秒进入歌曲。

playlist.insert(file, gain, peak, nextPlaylistItem)

使用文件创建一个新的播放列表项并将其放入之前的播放列表中 <代码>下一个播放列表项。 如果 nextPlaylistItemnull,则附加新的 项添加到播放列表。

gain 是仅适用于此项目的浮点格式音量调整。 默认为 1.0

peak 为 float 格式,参见 item.peak。 默认为 1.0

返回新添加的播放列表项。

将文件添加到播放列表后,您不能 file.close() 它直到 您首先将其从播放列表中删除。

playlist.remove(playlistItem)

从播放列表中删除 playlistItem

请注意,您有责任对每个文件调用 file.close() 您使用 groove.open 打开。 playlist.remove 不会关闭文件。

playlist.position()

返回 {item, pos} 其中 item 是当前播放列表项 decoded 和 pos 是解码头进入歌曲的秒数。

请注意,通常您对播放头的位置更感兴趣, 不是解码头。 返回播放头的示例方法是 player.position()encoder.position()

playlist.playing()

返回 truefalse

playlist.clear()

删除所有播放列表项。

playlist.count()

播放列表中有多少项目。

playlist.gain

playlist.setGain(value)

在 0.0 和 1.0 之间。 您可能希望将其保留为 1.0,因为使用 replaygain 通常会大大降低您的音量。

playlist.setItemGainPeak(playlistItem, gain, peak)

gain 是一个浮点数,它只影响指定播放列表项的音量。 要从 dB 转换为浮点数,请使用 exp(log(10) * 0.05 * dBValue)。

请参阅 item.peak

playlist.setFillMode(mode)

mode 可以是:

  • groove.EVERY_SINK_FULL

    如果任何接收器未满,播放列表将解码音频。 如果有任何汇 耗尽速度不够快,数据将缓冲在播放列表中。

  • groove.ANY_SINK_FULL

    这是默认行为。 使用此行为,播放列表将停止 当任何连接的接收器已满时解码音频,然后恢复解码 音频每个水槽都没有装满。

默认为 groove.EVERY_SINK_FULL

GroovePlaylistItem

这些不是直接实例化的; 相反,它们是从 playlist.items()

GroovePlaylistItem 只是指向 GroovePlaylist 的指针。 如果你 从播放列表中删除播放列表项目,任何播放列表项目引用您 到处都是悬垂的指针。

item.file

只读。

item.gain

播放文件时应用到文件的浮动格式的音量调整。 这通常用于响度补偿,例如 ReplayGain。 要从 dB 转换为浮点数,请使用 groove.dBToFloat

只读。 使用playlist.setItemGain修改。

item.peak

此播放列表项目的样本峰值假定为 1.0 浮点数 格式。 如果您确定峰值小于 1.0,您 可以设置这个值,这可能允许音量调整使用 纯放大器而不是压缩器。 这导致稍微 更好的音频质量。

只读。 使用playlist.setItemPeak 修改。

item.id

每次从 groove 中获得一个播放列表项目,您将获得一个新的 JavaScript 对象,但它可能指向相同的底层 libgroove 指针 作为另一个。 id 字段是一种检查两个播放列表项是否引用的方法 同一个。

只读。

GroovePlayer

groove.getDevices()

在调用此函数之前,您必须先调用 <代码>groove.connectSoundBackend()

返回一个像这样的对象:

{
  list: [
    {
      name: "User-Friendly Device Name",
      id: "unique device ID that persists across plugs and unplugs",
      isRaw: false, // true if this device would claim exclusive access
      probeError: 3, // non zero if scanning this device did not work
    },
    //...
  ],
  defaultIndex: 0,
}

groove.connectSoundBackend([backend])

backend 是可选的。 如果留空,最好的后端是自动的 选择。 否则它可以是以下之一:

  • groove.BACKEND_JACK
  • groove.BACKEND_PULSEAUDIO
  • groove.BACKEND_ALSA
  • groove.BACKEND_COREAUDIO
  • groove.BACKEND_WASAPI
  • groove.BACKEND_DUMMY

groove.disconnectSoundBackend()

groove.createPlayer()

创建一个 GroovePlayer 实例,然后您可以通过设置对其进行配置 特性。

player.device

在调用 attach() 之前,将其设置为其中一个设备 从 groove.getDevices() 返回。

player.attach(playlist, callback)

将音频发送到声音设备。

callback(err)

player.detach(callback)

callback(err)

player.position()

返回 {item, pos} 其中 item 是当前播放列表项 played 和 pos 是播放头进入歌曲的秒数。

player.on('nowplaying', handler)

当正在播放的项目改变时触发。 它可以是 null

handler()

player.on('bufferunderrun', handler)

当发生缓冲区欠载时触发。 理想情况下,您永远不会看到这一点。

handler()

player.on('devicereopened', handler)

当您将 useExactAudioFormat 设置为 true 并且音频设备时触发 已关闭并重新打开以匹配传入的音频数据。

handler()

GrooveEncoder

groove.createEncoder()

encoder.bitRate

通过选择一个

encoder.formatShortName

可选的目标比特率来选择编码质量——帮助 libgroove 猜测要使用的格式。 avconv -formats 以获得可能性列表。

encoder.codecShortName

可选 - 帮助 libgroove 猜测使用哪个编解码器。 avconv-codecs 以获得可能性列表。

encoder.filename

可选 - 提供示例文件名以帮助 libgroove 猜测 使用哪种格式/编解码器。

encoder.mimeType

可选 - 提供 mime 类型字符串以帮助 libgrooove 猜测 使用哪种格式/编解码器。

encoder.targetAudioFormat

用于编码的所需音频格式设置。 groove.createEncoder() 默认为 44100 Hz, 带符号的 16 位整数,立体声。 这些是偏好; 如果不能使用设置,替代品将 被使用。 在这种情况下,actualAudioFormat 将被更新以反映 替代值。

属性:

  • sampleRate
  • channelLayout - array of channel ids
  • sampleFormat

encoder.actualAudioFormat

groove 将其设置为附加编码器时获得的实际格式。 理想情况下与 targetAudioFormat 相同,但也可能不同。

属性:

  • sampleRate
  • channelLayout - array of channel ids
  • sampleFormat

encoder.sinkBufferSize

接收器缓冲区应该有多大,以样本帧为单位。 createEncoder 默认为 8192

encoder.encodedBufferSize

编码的音频缓冲区应该有多大,以字节为单位。 createEncoder 默认为 16384

encoder.attach(playlist, callback)

callback(err)

encoder.detach(callback)

callback(err)</

encoder.getBuffer()

code> 如果没有缓冲区可用则返回 null,或者具有以下属性的对象:

  • buffer - a node Buffer instance which is the encoded data for this chunk this can be null in which case this buffer is actually the end of playlist sentinel.
  • item - the GroovePlaylistItem of which this buffer is encoded data for
  • pos - position in seconds that this buffer represents in into the item

encoder.on('buffer', handler)

handler()

当有缓冲区可供获取时发出。 你仍然需要得到 使用 getBuffer() 缓冲。

encoder.position()

返回 {item, pos} 其中 item 是当前播放列表项 encoded 和 pos 是编码头进入歌曲的秒数。

GrooveLoudnessDetector

groove.createLoudnessDetector()

返回一个 GrooveLoudnessDetector

detector.infoQueueSize

设置它以确定播放列表中要看多远。

detector.disableAlbum

设置为 true 以仅计算音轨响度。 这更快,需要更少 内存比计算两者。

detector.attach(playlist, callback)

callback(err)

detector.detach(callback)

callback(err)</

detector.getInfo()

code> 如果没有可用信息或具有以下属性的对象,则返回 null

  • loudness - loudness in LUFS
  • peak - sample peak in float format of the file
  • duration - duration in seconds of the track
  • item - the GroovePlaylistItem that this applies to, or null if it applies to the entire album.

detector.position()

返回 {item, pos} 其中 item 是当前正在播放的播放列表项 detected 和 pos 是检测头进入歌曲的秒数。

detector.on('info', handler)

handler()

当有信息可供获取时发出。 您仍然需要获取信息 使用 getInfo()

GrooveFingerprinter

groove.createFingerprinter()

返回一个 GrooveFingerprinter

groove.encodeFingerprint(rawFingerprint)

给定一个整数数组,它是原始指纹,将它编码成一个 可以提交给 acoustid.org 的字符串。

groove.decodeFingerprint(fingerprint)

给定指纹字符串,返回原始整数列表 指纹数据。

printer.infoQueueSize

设置此项以确定播放列表中要看多远。

printer.attach(playlist, callback)

callback(err)

printer.detach(callback)

callback(err)</

printer.getInfo()

code> 如果没有可用信息或具有以下属性的对象,则返回 null

  • fingerprint - integer array which is the raw fingerprint
  • duration - duration in seconds of the track
  • item - the GroovePlaylistItem that this applies to, or null if it applies to the entire album.

printer.position()

返回 {item, pos} 其中 item 是当前正在播放的播放列表项 fingerprinted 和 pos 是打印机头进入歌曲的秒数。

printer.on('info', handler)

handler()

当有信息可供获取时发出。 您仍然需要获取信息 使用 getInfo()

GrooveWaveformBuilder

groove.createWaveformBuilder()

返回一个 GrooveWaveformBuilder

waveform.widthInFrames

波形数据将有多少帧宽。 默认为 1920。

如果您有一首 100 帧的歌曲,并且 widthInFrames 为 50,则每个 波形数据帧会对应原曲的2帧。

printer.infoQueueSizeBytes

设置此项以确定播放列表中要看多远。

waveform.attach(playlist, callback)

callback(err)

waveform.detach(callback)

callback(err)</

waveform.getInfo()

code> 如果没有可用信息或具有以下属性的对象,则返回 null

  • buffer - A Buffer of the waveform data, one unsigned 8 bit integer per widthInFrames.
  • expectedDuration - This is the duration in seconds that was used to create the waveform data. If this is different than actualDuration then the data is invalid and must be re-calculated, this time using file.overrideDuration()
  • actualDuration - This is the correct duration in seconds for the track, known only after waveform calculation is complete.
  • item - the GroovePlaylistItem that this applies to, or null if this info signals the end of playlist.

waveform.position()

返回 {item, pos} 其中 item 是当前正在播放的播放列表项 计算出 pos 是波形头进入歌曲的秒数。

waveform.on('info', handler)

handler()

当有信息可供获取时发出。 您仍然需要获取信息 使用 getInfo()

node-groove

Node.js bindings to libgroove - generic music player backend library.

Live discussion in #libgroove on freenode.

Here are the main interfaces. See API Documentation below for more details.

  • GrooveFile - represents an open audio file.
  • GroovePlaylist - put files in the playlist, and the playlist decodes the files and fills up the attached sinks.
  • GroovePlayer - attach this sink to a playlist to play the decoded audio over the system's speakers.
  • GrooveEncoder - attach this sink to a playlist to obtain encoded audio buffers, such as an mp3 stream.
  • GrooveLoudnessDetector - attach this sink to a playlist to compute how loud files sound to the human ear, along with the "true peak" value. You can use this to implement ReplayGain.
  • GrooveFingerprinter - attach this sink to a playlist to compute an acoustid fingerprint. This can be used to look up a file by its audio content and figure out which tags should be applied.
  • GrooveWaveformBuilder - attach this sink to a playlist to compute a JSON representation of an audio file. This can be used to display a visualization of the audio file.

Usage

  1. Install libgroove to your system. libgroove is a set of 4 libraries; node-groove depends on all of them. So for example on ubuntu, make sure to install libgroove-dev, libgrooveplayer-dev, libgrooveloudness-dev, and libgroovefingerprinter-dev.
  2. npm install --save groove

Versions

  • node-groove >=3.0.0 depends on libgroove >=5.0.0
  • node-groove >=2.4.0 <3.0.0 depends on libgroove >=4.3.0 <5.0.0
  • node-groove 2.3.4 depends on libgroove <4.3.0

See CHANGELOG.md for release notes and upgrade guide.

Get Metadata from File

var groove = require('groove');

groove.open("danse-macabre.ogg", function(err, file) {
  if (err) throw err;
  console.log(file.metadata());
  console.log("duration:", file.duration());
  file.close(function(err) {
    if (err) throw err;
  });
});

More Examples

  • example/metadata.js - read or update metadata in a media file
  • example/playlist.js - play several files in a row and then exit
  • example/replaygain.js - compute replaygain values for media files
  • example/transcode.js - convert and splice several files together
  • example/fingerprint.js - create an acoustid fingerprint for media files
  • example/devices.js - list the playback devices on the system
  • example/waveform.js - calculate a waveformjs compatible representation of a media file

API Documentation

globals

groove.setLogging(level)

level can be:

  • groove.LOG_QUIET
  • groove.LOG_ERROR
  • groove.LOG_WARNING
  • groove.LOG_INFO

groove.loudnessToReplayGain(loudness)

Converts a loudness value which is in LUFS to the ReplayGain-suggested dB adjustment.

groove.dBToFloat(dB)

Converts dB format volume adjustment to a floating point gain format.

groove.getVersion()

Returns an object with these properties:

  • major
  • minor
  • patch

GrooveFile

groove.open(filename, callback)

callback(err, file)

file.close(callback)

callback(err)

file.duration()

In seconds.

file.shortNames()

A comma-separated list of short names for the format.

file.getMetadata(key, [flags])

Flags:

  • groove.TAG_MATCH_CASE
  • groove.TAG_DONT_OVERWRITE
  • groove.TAG_APPEND

file.setMetadata(key, value, [flags])

See getMetadata for flags.

Pass null for value to delete a key.

file.metadata()

This returns an object populated with all the metadata. Updating the object does nothing. Use setMetadata to update metadata and then save to write changes to disk.

file.dirty

Boolean whether save will do anything.

file.filename

The string that was passed to groove.open

file.overrideDuration(duration)

If you know for sure the actual duration of the file, call this function to set the actual duration in seconds of the file. GrooveWaveformBuilder will use this value instead of file.duration().

This must only be called when no GroovePlaylistItem references to this file.

file.save(callback)

callback(err)

GroovePlaylist

groove.createPlaylist()

A playlist managers keeping an audio buffer full. To send the buffer to your speakers, use playlist.createPlayer().

Note: you probably only want one playlist. In node-groove, a playlist is a low-level audio processing concept, not to be confused with user-facing playlists where users might add, remove, and re-order songs.

playlist.destroy()

When finished with your playlist you must destroy it.

playlist.items()

Returns a read-only array of playlist items. Use playlist.insert and playlist.remove to modify.

[playlistItem1, playlistItem2, ...]

playlist.play()

playlist.pause()

playlist.seek(playlistItem, position)

Seek to playlistItem, position seconds into the song.

playlist.insert(file, gain, peak, nextPlaylistItem)

Creates a new playlist item with file and puts it in the playlist before nextPlaylistItem. If nextPlaylistItem is null, appends the new item to the playlist.

gain is a float format volume adjustment that applies only to this item. defaults to 1.0

peak is float format, see item.peak. defaults to 1.0

Returns the newly added playlist item.

Once you add a file to the playlist, you must not file.close() it until you first remove it from the playlist.

playlist.remove(playlistItem)

Remove playlistItem from the playlist.

Note that you are responsible for calling file.close() on every file that you open with groove.open. playlist.remove will not close files.

playlist.position()

Returns {item, pos} where item is the playlist item currently being decoded and pos is how many seconds into the song the decode head is.

Note that typically you are more interested in the position of the play head, not the decode head. Example methods which return the play head are player.position() and encoder.position().

playlist.playing()

Returns true or false.

playlist.clear()

Remove all playlist items.

playlist.count()

How many items are on the playlist.

playlist.gain

playlist.setGain(value)

Between 0.0 and 1.0. You probably want to leave this at 1.0, since using replaygain will typically lower your volume a significant amount.

playlist.setItemGainPeak(playlistItem, gain, peak)

gain is a float that affects the volume of the specified playlist item only. To convert from dB to float, use exp(log(10) * 0.05 * dBValue).

See item.peak

playlist.setFillMode(mode)

mode can be:

  • groove.EVERY_SINK_FULL

    The playlist will decode audio if any sinks are not full. If any sinks do not drain fast enough the data will buffer up in the playlist.

  • groove.ANY_SINK_FULL

    This is the default behavior. With this behavior, the playlist will stop decoding audio when any attached sink is full, and then resume decoding audio every sink is not full.

Defaults to groove.EVERY_SINK_FULL.

GroovePlaylistItem

These are not instantiated directly; instead they are returned from playlist.items().

A GroovePlaylistItem is merely a pointer into a GroovePlaylist. If you remove a playlist item from a playlist, any playlist item references you have lying around become dangling pointers.

item.file

Read-only.

item.gain

A volume adjustment in float format to apply to the file when it plays. This is typically used for loudness compensation, for example ReplayGain. To convert from dB to float, use groove.dBToFloat

Read-only. Use playlist.setItemGain to modify.

item.peak

The sample peak of this playlist item is assumed to be 1.0 in float format. If you know for certain that the peak is less than 1.0, you may set this value which may allow the volume adjustment to use a pure amplifier rather than a compressor. This results in slightly better audio quality.

Read-only. Use playlist.setItemPeak to modify.

item.id

Every time you obtain a playlist item from groove, you will get a fresh JavaScript object, but it might point to the same underlying libgroove pointer as another. The id field is a way to check if two playlist items reference the same one.

Read-only.

GroovePlayer

groove.getDevices()

Before you can call this function, you must call groove.connectSoundBackend().

Returns an object like this:

{
  list: [
    {
      name: "User-Friendly Device Name",
      id: "unique device ID that persists across plugs and unplugs",
      isRaw: false, // true if this device would claim exclusive access
      probeError: 3, // non zero if scanning this device did not work
    },
    //...
  ],
  defaultIndex: 0,
}

groove.connectSoundBackend([backend])

backend is optional. If left blank the best backend is automatically selected. Otherwise it can be one of these:

  • groove.BACKEND_JACK
  • groove.BACKEND_PULSEAUDIO
  • groove.BACKEND_ALSA
  • groove.BACKEND_COREAUDIO
  • groove.BACKEND_WASAPI
  • groove.BACKEND_DUMMY

groove.disconnectSoundBackend()

groove.createPlayer()

Creates a GroovePlayer instance which you can then configure by setting properties.

player.device

Before calling attach(), set this to one of the devices returned from groove.getDevices().

player.attach(playlist, callback)

Sends audio to sound device.

callback(err)

player.detach(callback)

callback(err)

player.position()

Returns {item, pos} where item is the playlist item currently being played and pos is how many seconds into the song the play head is.

player.on('nowplaying', handler)

Fires when the item that is now playing changes. It can be null.

handler()

player.on('bufferunderrun', handler)

Fires when a buffer underrun occurs. Ideally you'll never see this.

handler()

player.on('devicereopened', handler)

Fires when you have set useExactAudioFormat to true and the audio device has been closed and re-opened to match incoming audio data.

handler()

GrooveEncoder

groove.createEncoder()

encoder.bitRate

select encoding quality by choosing a target bit rate

encoder.formatShortName

optional - help libgroove guess which format to use. avconv -formats to get a list of possibilities.

encoder.codecShortName

optional - help libgroove guess which codec to use. avconv-codecs to get a list of possibilities.

encoder.filename

optional - provide an example filename to help libgroove guess which format/codec to use.

encoder.mimeType

optional - provide a mime type string to help libgrooove guess which format/codec to use.

encoder.targetAudioFormat

The desired audio format settings with which to encode. groove.createEncoder() defaults these to 44100 Hz, signed 16-bit int, stereo. These are preferences; if a setting cannot be used, a substitute will be used instead. In this case, actualAudioFormat will be updated to reflect the substituted values.

Properties:

  • sampleRate
  • channelLayout - array of channel ids
  • sampleFormat

encoder.actualAudioFormat

groove sets this to the actual format you get when you attach the encoder. Ideally will be the same as targetAudioFormat but might not be.

Properties:

  • sampleRate
  • channelLayout - array of channel ids
  • sampleFormat

encoder.sinkBufferSize

How big the sink buffer should be, in sample frames. createEncoder defaults this to 8192

encoder.encodedBufferSize

How big the encoded audio buffer should be, in bytes. createEncoder defaults this to 16384

encoder.attach(playlist, callback)

callback(err)

encoder.detach(callback)

callback(err)

encoder.getBuffer()

Returns null if no buffer available, or an object with these properties:

  • buffer - a node Buffer instance which is the encoded data for this chunk this can be null in which case this buffer is actually the end of playlist sentinel.
  • item - the GroovePlaylistItem of which this buffer is encoded data for
  • pos - position in seconds that this buffer represents in into the item

encoder.on('buffer', handler)

handler()

Emitted when there is a buffer available to get. You still need to get the buffer with getBuffer().

encoder.position()

Returns {item, pos} where item is the playlist item currently being encoded and pos is how many seconds into the song the encode head is.

GrooveLoudnessDetector

groove.createLoudnessDetector()

returns a GrooveLoudnessDetector

detector.infoQueueSize

Set this to determine how far ahead into the playlist to look.

detector.disableAlbum

Set to true to only compute track loudness. This is faster and requires less memory than computing both.

detector.attach(playlist, callback)

callback(err)

detector.detach(callback)

callback(err)

detector.getInfo()

Returns null if no info available, or an object with these properties:

  • loudness - loudness in LUFS
  • peak - sample peak in float format of the file
  • duration - duration in seconds of the track
  • item - the GroovePlaylistItem that this applies to, or null if it applies to the entire album.

detector.position()

Returns {item, pos} where item is the playlist item currently being detected and pos is how many seconds into the song the detect head is.

detector.on('info', handler)

handler()

Emitted when there is info available to get. You still need to get the info with getInfo().

GrooveFingerprinter

groove.createFingerprinter()

returns a GrooveFingerprinter

groove.encodeFingerprint(rawFingerprint)

Given an Array of integers which is the raw fingerprint, encode it into a string which can be submitted to acoustid.org.

groove.decodeFingerprint(fingerprint)

Given the fingerprint string, returns a list of integers which is the raw fingerprint data.

printer.infoQueueSize

Set this to determine how far ahead into the playlist to look.

printer.attach(playlist, callback)

callback(err)

printer.detach(callback)

callback(err)

printer.getInfo()

Returns null if no info available, or an object with these properties:

  • fingerprint - integer array which is the raw fingerprint
  • duration - duration in seconds of the track
  • item - the GroovePlaylistItem that this applies to, or null if it applies to the entire album.

printer.position()

Returns {item, pos} where item is the playlist item currently being fingerprinted and pos is how many seconds into the song the printer head is.

printer.on('info', handler)

handler()

Emitted when there is info available to get. You still need to get the info with getInfo().

GrooveWaveformBuilder

groove.createWaveformBuilder()

returns a GrooveWaveformBuilder

waveform.widthInFrames

How many frames wide the waveform data will be. Defaults to 1920.

If you have a song with 100 frames and widthInFrames is 50, then each waveform data frame will correspond to 2 frames of the original song.

printer.infoQueueSizeBytes

Set this to determine how far ahead into the playlist to look.

waveform.attach(playlist, callback)

callback(err)

waveform.detach(callback)

callback(err)

waveform.getInfo()

Returns null if no info available, or an object with these properties:

  • buffer - A Buffer of the waveform data, one unsigned 8 bit integer per widthInFrames.
  • expectedDuration - This is the duration in seconds that was used to create the waveform data. If this is different than actualDuration then the data is invalid and must be re-calculated, this time using file.overrideDuration()
  • actualDuration - This is the correct duration in seconds for the track, known only after waveform calculation is complete.
  • item - the GroovePlaylistItem that this applies to, or null if this info signals the end of playlist.

waveform.position()

Returns {item, pos} where item is the playlist item currently being calculated and pos is how many seconds into the song the waveform head is.

waveform.on('info', handler)

handler()

Emitted when there is info available to get. You still need to get the info with getInfo().

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文