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 @@
harray() -> HArray
source
+
harray() -> HArray
source
Get the decoded HArray.
sr() -> integer
source
+
sr() -> integer
source
Get the sampling rate of the decoded audio.
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 @@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 @@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 @@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.
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 @@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 @@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 @@Load the library
+Load the library.
library(harmonium)
Create an HArray
from an existing array
Create an HArray
from an existing array.
= matrix(c(1,2,3,4,5,6,7,8,9,10,11,12), ncol = 2)
- arr = HDataType$float64
- dtype = HArray$new_from_values(arr, dtype = dtype)
+ harray = HDataType$Float64
+ dtype = HArray$new_from_values(arr, dtype)
harray print(harray)
Or decode from an existing audio file
-= HFile$decode("file.wav", dtype)
- l = l[[0]]
- harray = l[[1]] # sampling rate
+ sr Or decode from an existing audio file.
+= HFile$decode("file.wav", dtype)
+ decoded_audio = decoded_audio$harray()
+ harray = decoded_audio$sr() # sampling rate
sr print(harray)
-Verify the dimensions
+Verify the dimensions.
$len()
harray$nchannels(harray)
HAudioOp$nframes(harray) HAudioOp
-Verify the data type
+Verify the data type.
$dtype() harray
-Convert to an R array
+Convert to an R array.
$collect() harray
-Convert to mono
-$to_mono(harray) HAudioOp
-Resample the haudio
-= 48000L
- sr_in = 22050L
- sr_out = HAudioOp$nchannels(harray)
- nbr_channels = HDataType$float64
- dtype = HResamplerType$fft_fixed_in
- res_type = HResampler$new_fft(sr_in, sr_out, nbr_channels, res_type)
- resampler $process(harray) hresampler
-Play the haudio
-= HAudioSink$new()
- haudiosink $append_from_harray(harray) haudiosink
-Or play directly from the file
-$append_from_file("file.wav") haudiosink
-Get the number of audios to be played
+Convert to mono.
+$to_mono(harray)
+ HAudioOpprint(harray)
+Resample the haudio.
+= matrix(as.double(1:8192), ncol = 2)
+ arr = HDataType$Float64
+ dtype = HArray$new_from_values(arr, dtype)
+ harray = 48000L
+ sr_in = 44100L
+ sr_out = 1024L
+ chunk_size = 2L
+ sub_chunks = 2L
+ nbr_channels = HResamplerType$FftFixedIn
+ res_type = HDataType$Float64
+ dtype = HResampler$new_fft(sr_in, sr_out, chunk_size, sub_chunks, nbr_channels, res_type, dtype)
+ hresampler $process(harray) hresampler
+Play the haudio.
+= HDataType$Float32
+ dtype = HFile$decode("file.wav", dtype)
+ decoded_audio = decoded_audio$harray()
+ harray = decoded_audio$sr() # sampling rate
+ sr = HAudioSink$new()
+ haudiosink $append_from_harray(harray, sr) haudiosink
+Or play directly from the file.
+= HAudioSink$new()
+ haudiosink $append_from_file("file.wav") haudiosink
+Get the number of audios to be played.
$len() haudiosink
-Double the audio volume and the playback speed
+Double the audio volume and the playback speed.
$set_volume(2)
haudiosink$set_speed(2) haudiosink
-Pause the playback and confirms it is paused
+Pause the playback and confirms it is paused.
$pause()
haudiosink$is_paused() haudiosink
-It is also possible to get metadata from an audio file
-= HMetadataType$text
+ metatadatype It is also possible to get metadata from an audio file.
+= HMetadataType$Text
metatadatype $metadata("file.wav", metatadatype) HFile
-And to get some audio parameters directly from a file
+And to get some audio parameters directly from a file.
= HFile$params("file.wav")
params = params[[1]]
sr = 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",
nframes