diff --git a/docs/index.html b/docs/index.html index d2759de..224130f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -303,10 +303,13 @@

Basic usage

harray = HArray$new_from_values(arr, dtype) print(harray)

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)
+
harmonium_path = system.file(package = "harmonium")
+filepath = file.path(harmonium_path, "testfiles", "gs-16b-2c-44100hz.flac")
+dtype = HDataType$Float64
+decoded_audio = HFile$decode(filepath, dtype)
+harray = decoded_audio$harray()
+sr = decoded_audio$sr() # sampling rate
+print(harray)

Verify the dimensions.

harray$len()
 HAudioOp$nchannels(harray)
@@ -332,15 +335,19 @@ 

Basic usage

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)
+
harmonium_path = system.file(package = "harmonium")
+filepath = file.path(harmonium_path, "testfiles", "gs-16b-2c-44100hz.flac")
+dtype = HDataType$Float32
+decoded_audio = HFile$decode(filepath, 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")
+
harmonium_path = system.file(package = "harmonium")
+filepath = file.path(harmonium_path, "testfiles", "gs-16b-2c-44100hz.flac")
+haudiosink = HAudioSink$new()
+haudiosink$append_from_file(filepath)

Get the number of audios to be played.

haudiosink$len()

Double the audio volume and the playback speed.

@@ -350,14 +357,18 @@

Basic usage

haudiosink$pause()
 haudiosink$is_paused()

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

-
metatadatype = HMetadataType$Text
-HFile$metadata("file.wav", metatadatype)
+
harmonium_path = system.file(package = "harmonium")
+filepath = file.path(harmonium_path, "testfiles", "gs-16b-2c-44100hz.flac")
+metatadatype = HMetadataType$Text
+HFile$metadata(filepath, metatadatype)

And to get some audio parameters directly from a file.

-
params = HFile$params("file.wav")
-sr = params[[1]]
-nframes = params[[2]]
-nchannels = params[[3]]
-duration = params[[4]]
+
harmonium_path = system.file(package = "harmonium")
+filepath = file.path(harmonium_path, "testfiles", "gs-16b-2c-44100hz.flac")
+params = HFile$params(filepath)
+sr = params[[1]]
+nframes = params[[2]]
+nchannels = params[[3]]
+duration = params[[4]]
diff --git a/docs/search.json b/docs/search.json index 66aff8f..a18b44f 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)\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]]" + "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.\nharmonium_path = system.file(package = \"harmonium\")\nfilepath = file.path(harmonium_path, \"testfiles\", \"gs-16b-2c-44100hz.flac\")\ndtype = HDataType$Float64\ndecoded_audio = HFile$decode(filepath, 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.\nharmonium_path = system.file(package = \"harmonium\")\nfilepath = file.path(harmonium_path, \"testfiles\", \"gs-16b-2c-44100hz.flac\")\ndtype = HDataType$Float32\ndecoded_audio = HFile$decode(filepath, 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.\nharmonium_path = system.file(package = \"harmonium\")\nfilepath = file.path(harmonium_path, \"testfiles\", \"gs-16b-2c-44100hz.flac\")\nhaudiosink = HAudioSink$new()\nhaudiosink$append_from_file(filepath)\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.\nharmonium_path = system.file(package = \"harmonium\")\nfilepath = file.path(harmonium_path, \"testfiles\", \"gs-16b-2c-44100hz.flac\")\nmetatadatype = HMetadataType$Text\nHFile$metadata(filepath, metatadatype)\nAnd to get some audio parameters directly from a file.\nharmonium_path = system.file(package = \"harmonium\")\nfilepath = file.path(harmonium_path, \"testfiles\", \"gs-16b-2c-44100hz.flac\")\nparams = HFile$params(filepath)\nsr = params[[1]]\nnframes = params[[2]]\nnchannels = params[[3]]\nduration = params[[4]]" }, { "objectID": "about.html",