ai-make-music

A powerful Elixir library for programmatically generating music using AI models. This package provides a simple and efficient way to integrate AI-powered music creation into your Elixir applications.

Installation

To install ai-make-music, add it as a dependency to your mix.exs file: elixir def deps do [

{:ai_make_music, "~> 0.1.0"}

] end

Then, run mix deps.get to fetch the dependency.

Usage

Here are a few examples demonstrating how to use ai-make-music in your Elixir projects.

Example 1: Generating a short melody elixir {:ok, melody} = AI.MakeMusic.generate_melody(%{duration: 10, style: "classical"})

IO.puts "Generated Melody: #{melody}"

Example 2: Creating a drum beat with specific parameters elixir AI.MakeMusic.generate_drum_beat(%{tempo: 120, genre: "rock"}) |> case do {:ok, drum_beat} ->

IO.puts "Generated Drum Beat: #{drum_beat}"

->

IO.puts "Error generating drum beat: #{reason}"

end

Example 3: Composing a full song with error handling elixir with {:ok, intro} <- AI.MakeMusic.generate_intro(%{style: "pop", duration: 15}),

 {:ok, verse} <- AI.MakeMusic.generate_verse(%{style: "pop", duration: 30}),
 {:ok, chorus} <- AI.MakeMusic.generate_chorus(%{style: "pop", duration: 20}) do

song = intro <> verse <> chorus IO.puts "Generated Song: #{song}"

else {:error, reason} ->

IO.puts "Error during song composition: #{reason}"

end

Example 4: Generating variations of an existing theme elixir theme = "C-G-Am-F" AI.MakeMusic.generate_variations(theme, %{num_variations: 3}) |> Enum.each(fn {:ok, variation} -> IO.puts "Variation: #{variation}" {:error, reason} -> IO.puts "Error generating variation: #{reason}" end)

Example 5: Pattern matching on different success/failure scenarios elixir AI.MakeMusic.generate_music(%{type: "ambient", length: 60}) |> case do {:ok, music, %{metadata: metadata}} ->

IO.puts "Generated Ambient Music: #{music}"
IO.puts "Metadata: #{metadata}"

->

IO.puts "Error: Invalid music type requested."

->

IO.puts "Unexpected error: #{reason}"

end

Features

License

MIT

This package is part of the ai-make-music ecosystem. For advanced features and enterprise-grade tools, visit: https://supermaker.ai/music/ai-make-music/