Skip to content

Implement fugue generator from melody subject - #1

Draft
kowtom with Copilot wants to merge 4 commits into
mainfrom
copilot/create-fugue-from-melody
Draft

Implement fugue generator from melody subject#1
kowtom with Copilot wants to merge 4 commits into
mainfrom
copilot/create-fugue-from-melody

Conversation

Copilot AI commented Nov 7, 2025

Copy link
Copy Markdown

Creates a program that generates three-voice fugues from a melody subject, outputting both text and MIDI formats.

Implementation

  • Core Engine (fuga.py):

    • Note class: Parses note notation (C4, D#4, Bb4, REST) with duration support, handles transposition
    • Voice class: Manages note sequences with timing
    • FugueGenerator: Implements traditional fugue structure:
      • Voice 1: Subject at t=0
      • Voice 2: Answer (subject +7 semitones) at t=subject_duration
      • Voice 3: Subject at t=subject_duration*1.5 (stretto)
    • MIDI export via midiutil library
  • Input Format: Text file with NoteName Duration per line

    • Supports sharps (#), flats (b), and REST
    • Fractional durations handled precisely (no truncation)
  • Error Handling: Warns on invalid notes/durations, continues processing valid entries

Example

Input (example_subject.txt):

C4 1.0
D4 1.0
E4 1.0
F4 1.0
G4 2.0

Output:

$ python fuga.py example_subject.txt
# Generates fugue.txt and fugue.mid

The text output displays all three voices with complete note sequences; MIDI file contains 3 tracks at 120 BPM.

Original prompt

Make a program which accomplishes the following task:
The program should make a fugue(musical composition) based on a melody (subject).
Input for the program is a text file with notes for one voice. Notes should be easy to edit with a text editor such as notepad.
The output should be also in text format and additionally a midi file should be generated.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits November 7, 2025 20:54
Co-authored-by: kowtom <18659597+kowtom@users.noreply.github.com>
Co-authored-by: kowtom <18659597+kowtom@users.noreply.github.com>
Co-authored-by: kowtom <18659597+kowtom@users.noreply.github.com>
Copilot AI changed the title [WIP] Create program to generate fugue from melody input Implement fugue generator from melody subject Nov 7, 2025
Copilot AI requested a review from kowtom November 7, 2025 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants