Professional integration for https://supermaker.ai/music/ai-make-music/
A JavaScript library for programmatically generating and manipulating music using AI. Seamlessly integrate AI-powered music creation into your applications.
Here are several examples demonstrating how to use the ai-make-music library in your JavaScript/Node.js projects:
1. Generating a Simple Melody:
javascript
const aiMakeMusic = require('ai-make-music');
async function generateMelody() {
try {
const melody = await aiMakeMusic.generateMelody({
style: 'classical',
tempo: 120,
length: 30, // Length in seconds
});
console.log('Generated Melody:', melody);
// You can then save the melody to a file or stream it.
} catch (error) {
console.error('Error generating melody:', error);
}
}
generateMelody();
2. Creating a Background Music Track for a Game:
javascript
const aiMakeMusic = require('ai-make-music');
async function createGameMusic() {
try {
const backgroundMusic = await aiMakeMusic.generateTrack({
genre: 'chiptune',
mood: 'upbeat',
duration: 60, // Duration in seconds
instrumentation: ['synth', '8bit'],
});
console.log('Generated Game Music:', backgroundMusic);
// Integrate the music into your game engine.
} catch (error) {
console.error('Error generating game music:', error);
}
}
createGameMusic();
3. Adding Harmonies to an Existing Melody:
javascript
const aiMakeMusic = require('ai-make-music');
async function addHarmony() {
const existingMelody = 'C4 D4 E4 F4 G4 A4 B4 C5'; // Example melody (replace with your actual melody)
try {
const harmony = await aiMakeMusic.addHarmony({
melody: existingMelody,
harmonyType: 'parallel',
key: 'C Major',
});
console.log('Melody with Harmony:', harmony);
// Combine the original melody with the generated harmony.
} catch (error) {
console.error('Error adding harmony:', error);
}
}
addHarmony();
4. Generating a Drum Beat:
javascript
const aiMakeMusic = require('ai-make-music');
async function generateDrumBeat() {
try {
const drumBeat = await aiMakeMusic.generateDrumBeat({
style: 'rock',
tempo: 140,
complexity: 'medium'
});
console.log('Generated Drum Beat:', drumBeat);
// Use the drum beat in your music composition.
} catch (error) {
console.error('Error generating drum beat:', error);
}
}
generateDrumBeat();
5. Generating a short Lo-Fi beat:
javascript
const aiMakeMusic = require('ai-make-music');
async function generateLoFiBeat() {
try {
const lofiBeat = await aiMakeMusic.generateTrack({
genre: 'lofi',
mood: 'chill',
duration: 30,
instrumentation: ['piano', 'bass', 'drums']
});
console.log('Generated Lo-Fi Beat:', lofiBeat);
// Use the beat in your project
} catch (error) {
console.error('Error generating Lo-Fi beat:', error);
}
}
generateLoFiBeat();
* generateMelody(options): Generates a melody based on the provided options.
* options: An object containing parameters like style, tempo, and length.
* generateTrack(options): Generates a complete music track with specified genre, mood, duration, and instrumentation.
* options: An object containing parameters like genre, mood, duration, and instrumentation.
* addHarmony(options): Adds a harmony to an existing melody.
* options: An object containing parameters like melody, harmonyType, and key.
* generateDrumBeat(options): Generates a drum beat.
* options: An object containing parameters like style, tempo, and complexity.
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/