utils

create_grains(file_name: str, file_location: str, grain_size=1024, grain_space=0, grain_offset=0, number_of_grains=8, checkpoint=None)
Parameters
  • file_name (string) – The name of the audio file to be granulated

  • file_location (string) – The path where the audio file is located

  • grain_size (int) – The size in samples of one grain

  • grain_space (int) – The size in samples of the chunck of audio to be granulated in the audio file

  • grain_offset (int) – The offset in samples of the start of the audio chuck to be granulated

  • number_of_grains (int) – The number of grains to generate

  • checkpoint (string) – The model checkpoint which will be used for encoding the grains

Returns

An array of encoded grains

Return type

array

encode_grains(grains, checkpoint: str)
Parameters
  • grains (array(array)) – An array of audio data to be encoded

  • checkpoint (string) – The name of the checkpoint to be used for encoding

Returns

An array of encoded grains

Return type

array

generate_grains(encoded_grains, checkpoint: str)
Parameters
  • encoded_grains (array) – A list of encoded grains to be synthesized back into audio

  • checkpoint (string) – The path and name of the checkpoint to use for synthesis

Returns

An array of audio buffers

Return type

array

interpolate_grains(encoded_grains, number_of_grains=8)
Parameters
  • encoded_grains (array(2)) – An array of encoded grains

  • number_of_grains (int) – The number of grains to generate from interpolation

Returns

An array of encoded grains

Return type

array

mix_two_grains(grains)
Parameters

grains (array(2)) – An array of encoded grains of the same size

Returns

A single grain

Return type

array

save_grain_cloud(grains, name='generated_grain_cloud')
Parameters
  • grains (array) – Array of grains to save

  • name (string) – The name of the file without extension