diff --git a/_docs/contents/hdecodedaudio.qmd b/_docs/contents/hdecodedaudio.qmd index 2beb3b0..ede9939 100644 --- a/_docs/contents/hdecodedaudio.qmd +++ b/_docs/contents/hdecodedaudio.qmd @@ -8,7 +8,7 @@ An audio represented by an HArray of samples and its corresponding sampling rate ## harray -`harray() -> HArray` [source](https://github.com/daniellga/harmonium/tree/master/r-harmonium/src/rust/src/hfile.rs#L63) \ +`harray() -> HArray` [source](https://github.com/daniellga/harmonium/tree/master/r-harmonium/src/rust/src/hfile.rs#L62) \ Get the decoded HArray. @@ -24,14 +24,13 @@ fpath = "../../../testfiles/gs-16b-2c-44100hz.flac" dtype = HDataType$Float32 hdecodedaudio = HFile$decode(fpath, dtype) hdecodedaudio$harray() - ``` _________ ## sr -`sr() -> integer` [source](https://github.com/daniellga/harmonium/tree/master/r-harmonium/src/rust/src/hfile.rs#L90) \ +`sr() -> integer` [source](https://github.com/daniellga/harmonium/tree/master/r-harmonium/src/rust/src/hfile.rs#L88) \ Get the sampling rate of the decoded audio. @@ -47,14 +46,13 @@ fpath = "../../../testfiles/gs-16b-2c-44100hz.flac" dtype = HDataType$Float32 hdecodedaudio = HFile$decode(fpath, dtype) hdecodedaudio$sr() - ``` _________ ## invalidate -`invalidate()` [source](https://github.com/daniellga/harmonium/tree/master/r-harmonium/src/rust/src/hfile.rs#L121) \ +`invalidate()` [source](https://github.com/daniellga/harmonium/tree/master/r-harmonium/src/rust/src/hfile.rs#L119) \ Replaces the inner value of the external pointer, invalidating it. diff --git a/_docs/contents/hdecoderstream.qmd b/_docs/contents/hdecoderstream.qmd index bcbbb1f..b8d7bff 100644 --- a/_docs/contents/hdecoderstream.qmd +++ b/_docs/contents/hdecoderstream.qmd @@ -8,7 +8,7 @@ An iterator that decodes audio in streams. ## stream -`stream() -> HArray` [source](https://github.com/daniellga/harmonium/tree/master/r-harmonium/src/rust/src/hfile.rs#L524) \ +`stream() -> HArray` [source](https://github.com/daniellga/harmonium/tree/master/r-harmonium/src/rust/src/hfile.rs#L522) \ Gets the next wave of frames as an `HArray`. diff --git a/_docs/contents/hfile.qmd b/_docs/contents/hfile.qmd index 8de604a..bdcaec9 100644 --- a/_docs/contents/hfile.qmd +++ b/_docs/contents/hfile.qmd @@ -8,7 +8,7 @@ A collection of methods designed to streamline input and output operations. ## decode -`decode(fpath: string, dtype: HDataType) -> HDecodedAudio` [source](https://github.com/daniellga/harmonium/tree/master/r-harmonium/src/rust/src/hfile.rs#L166) \ +`decode(fpath: string, dtype: HDataType) -> HDecodedAudio` [source](https://github.com/daniellga/harmonium/tree/master/r-harmonium/src/rust/src/hfile.rs#L164) \ Decode an audio file, providing its decoded data and the sampling rate. @@ -45,7 +45,7 @@ _________ ## decode_stream -`decode_stream(fpath: string, frames: integer, dtype: HDataType) -> HDecoderStream` [source](https://github.com/daniellga/harmonium/tree/master/r-harmonium/src/rust/src/hfile.rs#L224) \ +`decode_stream(fpath: string, frames: integer, dtype: HDataType) -> HDecoderStream` [source](https://github.com/daniellga/harmonium/tree/master/r-harmonium/src/rust/src/hfile.rs#L222) \ Creates an `HDecoderStream`, used as an iterator to stream frames of decoded audio. @@ -81,7 +81,7 @@ _________ ## metadata -`metadata(fpath: string, metadata_type: HMetadataType) -> list` [source](https://github.com/daniellga/harmonium/tree/master/r-harmonium/src/rust/src/hfile.rs#L366) \ +`metadata(fpath: string, metadata_type: HMetadataType) -> list` [source](https://github.com/daniellga/harmonium/tree/master/r-harmonium/src/rust/src/hfile.rs#L364) \ Extract text and visual metadata from a file. @@ -198,7 +198,7 @@ _________ ## params -`params(fpath: string) -> atomicvector` [source](https://github.com/daniellga/harmonium/tree/master/r-harmonium/src/rust/src/hfile.rs#L441) \ +`params(fpath: string) -> atomicvector` [source](https://github.com/daniellga/harmonium/tree/master/r-harmonium/src/rust/src/hfile.rs#L439) \ Get audio parameters from a file. @@ -231,7 +231,7 @@ _________ ## verify -`verify(fpath: string) -> string` [source](https://github.com/daniellga/harmonium/tree/master/r-harmonium/src/rust/src/hfile.rs#L481) \ +`verify(fpath: string) -> string` [source](https://github.com/daniellga/harmonium/tree/master/r-harmonium/src/rust/src/hfile.rs#L479) \ Verify an audio file, if supported by the decoder. diff --git a/docs/contents/hdecodedaudio.html b/docs/contents/hdecodedaudio.html index 02f3f89..5bb126a 100644 --- a/docs/contents/hdecodedaudio.html +++ b/docs/contents/hdecodedaudio.html @@ -301,7 +301,7 @@

HDecodedAudio

Methods

harray

-

harray() -> HArray source
+

harray() -> HArray source

Get the decoded HArray.

@@ -320,7 +320,7 @@

Examples

sr

-

sr() -> integer source
+

sr() -> integer source

Get the sampling rate of the decoded audio.

@@ -339,7 +339,7 @@

Examples

invalidate

-

invalidate() source
+

invalidate() source

Replaces the inner value of the external pointer, invalidating it.

This function is useful to remove one of the shared references of the inner pointer in rust.

diff --git a/docs/contents/hdecoderstream.html b/docs/contents/hdecoderstream.html index 1c20bc2..ddf122d 100644 --- a/docs/contents/hdecoderstream.html +++ b/docs/contents/hdecoderstream.html @@ -299,7 +299,7 @@

HDecoderStream

Methods

stream

-

stream() -> HArray source
+

stream() -> HArray source

Gets the next wave of frames as an HArray.

Returns an error if it’s end of stream or if an error ocurred in the decoding process.

diff --git a/docs/contents/hfile.html b/docs/contents/hfile.html index 74d6d89..2526519 100644 --- a/docs/contents/hfile.html +++ b/docs/contents/hfile.html @@ -303,7 +303,7 @@

HFile

Methods

decode

-

decode(fpath: string, dtype: HDataType) -> HDecodedAudio source
+

decode(fpath: string, dtype: HDataType) -> HDecodedAudio source

Decode an audio file, providing its decoded data and the sampling rate.

The samples are normalized to fit in the range of [-1.0, 1.0].

@@ -337,7 +337,7 @@

Examples

decode_stream

-

decode_stream(fpath: string, frames: integer, dtype: HDataType) -> HDecoderStream source
+

decode_stream(fpath: string, frames: integer, dtype: HDataType) -> HDecoderStream source

Creates an HDecoderStream, used as an iterator to stream frames of decoded audio.

@@ -371,7 +371,7 @@

Examples

metadata

-

metadata(fpath: string, metadata_type: HMetadataType) -> list source
+

metadata(fpath: string, metadata_type: HMetadataType) -> list source

Extract text and visual metadata from a file.

Tags that are part of the container format are preferentially extracted. Additional tags that were found while probing will not be extracted.

@@ -449,7 +449,7 @@

Examples

params

-

params(fpath: string) -> atomicvector source
+

params(fpath: string) -> atomicvector source

Get audio parameters from a file.

Note that this avoids loading the contents into memory, and is therefore useful for querying these parameters from long files.

@@ -480,7 +480,7 @@

Examples

verify

-

verify(fpath: string) -> string source
+

verify(fpath: string) -> string source

Verify an audio file, if supported by the decoder.

The verification is done after the decoding process is finished.

diff --git a/docs/index.html b/docs/index.html index 43d8738..d2759de 100644 --- a/docs/index.html +++ b/docs/index.html @@ -295,53 +295,64 @@

Harmonium

Basic usage

-

Load the library

+

Load the library.

library(harmonium)
-

Create an HArray from an existing array

+

Create an HArray from an existing array.

arr = matrix(c(1,2,3,4,5,6,7,8,9,10,11,12), ncol = 2)
-dtype = HDataType$float64
-harray = HArray$new_from_values(arr, dtype = dtype)
+dtype = HDataType$Float64
+harray = HArray$new_from_values(arr, dtype)
 print(harray)
-

Or decode from an existing audio file

-
l = HFile$decode("file.wav", dtype)
-harray = l[[0]]
-sr = l[[1]] # sampling rate
+

Or decode from an existing audio file.

+
decoded_audio = HFile$decode("file.wav", dtype)
+harray = decoded_audio$harray()
+sr = decoded_audio$sr() # sampling rate
 print(harray)
-

Verify the dimensions

+

Verify the dimensions.

harray$len()
 HAudioOp$nchannels(harray)
 HAudioOp$nframes(harray)
-

Verify the data type

+

Verify the data type.

harray$dtype()
-

Convert to an R array

+

Convert to an R array.

harray$collect()
-

Convert to mono

-
HAudioOp$to_mono(harray)
-

Resample the haudio

-
sr_in = 48000L
-sr_out = 22050L
-nbr_channels = HAudioOp$nchannels(harray)
-dtype = HDataType$float64
-res_type = HResamplerType$fft_fixed_in
-resampler = HResampler$new_fft(sr_in, sr_out, nbr_channels, res_type)
-hresampler$process(harray)
-

Play the haudio

-
haudiosink = HAudioSink$new()
-haudiosink$append_from_harray(harray)
-

Or play directly from the file

-
haudiosink$append_from_file("file.wav")
-

Get the number of audios to be played

+

Convert to mono.

+
HAudioOp$to_mono(harray)
+print(harray)
+

Resample the haudio.

+
arr = matrix(as.double(1:8192), ncol = 2)
+dtype = HDataType$Float64
+harray = HArray$new_from_values(arr, dtype)
+sr_in = 48000L
+sr_out = 44100L
+chunk_size = 1024L
+sub_chunks = 2L
+nbr_channels = 2L
+res_type = HResamplerType$FftFixedIn
+dtype = HDataType$Float64
+hresampler = HResampler$new_fft(sr_in, sr_out, chunk_size, sub_chunks, nbr_channels, res_type, dtype)
+hresampler$process(harray)
+

Play the haudio.

+
dtype = HDataType$Float32
+decoded_audio = HFile$decode("file.wav", dtype)
+harray = decoded_audio$harray()
+sr = decoded_audio$sr() # sampling rate
+haudiosink = HAudioSink$new()
+haudiosink$append_from_harray(harray, sr)
+

Or play directly from the file.

+
haudiosink = HAudioSink$new()
+haudiosink$append_from_file("file.wav")
+

Get the number of audios to be played.

haudiosink$len()
-

Double the audio volume and the playback speed

+

Double the audio volume and the playback speed.

haudiosink$set_volume(2)
 haudiosink$set_speed(2)
-

Pause the playback and confirms it is paused

+

Pause the playback and confirms it is paused.

haudiosink$pause()
 haudiosink$is_paused()
-

It is also possible to get metadata from an audio file

-
metatadatype = HMetadataType$text
+

It is also possible to get metadata from an audio file.

+
metatadatype = HMetadataType$Text
 HFile$metadata("file.wav", metatadatype)
-

And to get some audio parameters directly from a file

+

And to get some audio parameters directly from a file.

params = HFile$params("file.wav")
 sr = params[[1]]
 nframes = params[[2]]
diff --git a/docs/search.json b/docs/search.json
index 93ae359..66aff8f 100644
--- a/docs/search.json
+++ b/docs/search.json
@@ -598,7 +598,7 @@
     "href": "index.html",
     "title": "Harmonium",
     "section": "",
-    "text": "Harmonium is an audio interface inspired by Python’s librosa.\n\n\nBasic usage\nLoad the library\nlibrary(harmonium)\nCreate an HArray from an existing array\narr = matrix(c(1,2,3,4,5,6,7,8,9,10,11,12), ncol = 2)\ndtype = HDataType$float64\nharray = HArray$new_from_values(arr, dtype = dtype)\nprint(harray)\nOr decode from an existing audio file\nl = HFile$decode(\"file.wav\", dtype)\nharray = l[[0]]\nsr = l[[1]] # sampling rate\nprint(harray)\nVerify the dimensions\nharray$len()\nHAudioOp$nchannels(harray)\nHAudioOp$nframes(harray)\nVerify the data type\nharray$dtype()\nConvert to an R array\nharray$collect()\nConvert to mono\nHAudioOp$to_mono(harray)\nResample the haudio\nsr_in = 48000L\nsr_out = 22050L\nnbr_channels = HAudioOp$nchannels(harray)\ndtype = HDataType$float64\nres_type = HResamplerType$fft_fixed_in\nresampler = HResampler$new_fft(sr_in, sr_out, nbr_channels, res_type)\nhresampler$process(harray)\nPlay the haudio\nhaudiosink = HAudioSink$new()\nhaudiosink$append_from_harray(harray)\nOr play directly from the file\nhaudiosink$append_from_file(\"file.wav\")\nGet the number of audios to be played\nhaudiosink$len()\nDouble the audio volume and the playback speed\nhaudiosink$set_volume(2)\nhaudiosink$set_speed(2)\nPause the playback and confirms it is paused\nhaudiosink$pause()\nhaudiosink$is_paused()\nIt is also possible to get metadata from an audio file\nmetatadatype = HMetadataType$text\nHFile$metadata(\"file.wav\", metatadatype)\nAnd to get some audio parameters directly from a file\nparams = HFile$params(\"file.wav\")\nsr = params[[1]]\nnframes = params[[2]]\nnchannels = params[[3]]\nduration = params[[4]]"
+    "text": "Harmonium is an audio interface inspired by Python’s librosa.\n\n\nBasic usage\nLoad the library.\nlibrary(harmonium)\nCreate an HArray from an existing array.\narr = matrix(c(1,2,3,4,5,6,7,8,9,10,11,12), ncol = 2)\ndtype = HDataType$Float64\nharray = HArray$new_from_values(arr, dtype)\nprint(harray)\nOr decode from an existing audio file.\ndecoded_audio = HFile$decode(\"file.wav\", dtype)\nharray = decoded_audio$harray()\nsr = decoded_audio$sr() # sampling rate\nprint(harray)\nVerify the dimensions.\nharray$len()\nHAudioOp$nchannels(harray)\nHAudioOp$nframes(harray)\nVerify the data type.\nharray$dtype()\nConvert to an R array.\nharray$collect()\nConvert to mono.\nHAudioOp$to_mono(harray)\nprint(harray)\nResample the haudio.\narr = matrix(as.double(1:8192), ncol = 2)\ndtype = HDataType$Float64\nharray = HArray$new_from_values(arr, dtype)\nsr_in = 48000L\nsr_out = 44100L\nchunk_size = 1024L\nsub_chunks = 2L\nnbr_channels = 2L\nres_type = HResamplerType$FftFixedIn\ndtype = HDataType$Float64\nhresampler = HResampler$new_fft(sr_in, sr_out, chunk_size, sub_chunks, nbr_channels, res_type, dtype)\nhresampler$process(harray)\nPlay the haudio.\ndtype = HDataType$Float32\ndecoded_audio = HFile$decode(\"file.wav\", dtype)\nharray = decoded_audio$harray()\nsr = decoded_audio$sr() # sampling rate\nhaudiosink = HAudioSink$new()\nhaudiosink$append_from_harray(harray, sr)\nOr play directly from the file.\nhaudiosink = HAudioSink$new()\nhaudiosink$append_from_file(\"file.wav\")\nGet the number of audios to be played.\nhaudiosink$len()\nDouble the audio volume and the playback speed.\nhaudiosink$set_volume(2)\nhaudiosink$set_speed(2)\nPause the playback and confirms it is paused.\nhaudiosink$pause()\nhaudiosink$is_paused()\nIt is also possible to get metadata from an audio file.\nmetatadatype = HMetadataType$Text\nHFile$metadata(\"file.wav\", metatadatype)\nAnd to get some audio parameters directly from a file.\nparams = HFile$params(\"file.wav\")\nsr = params[[1]]\nnframes = params[[2]]\nnchannels = params[[3]]\nduration = params[[4]]"
   },
   {
     "objectID": "about.html",