Skip to content

Raga class incorrectly transforms stored ratios, loading wrong pitches #17

@jon-myers

Description

@jon-myers

Bug Report

Description:
The Raga class in the Python API is incorrectly transforming stored raga ratios during loading, resulting in wrong pitches being returned. This affects both get_pitches() and get_frequencies() methods.

Specific Issue:
For Rageshree (transcription ID: 68a3a79fffd9b2d478ee11e8), the stored raga data contains the correct 6 ratios with komal Ma and komal Ni, but the loaded Raga object has 7 different ratios including shuddha Ma, Pa, and shuddha Ni.

Expected Behavior:
The Raga class should preserve the exact ratios stored in the database without transformation.

Actual Behavior:
The ratios are transformed during loading, changing the musical content of the raga.

Evidence:

Raw stored raga data (correct):

  • 6 ratios: [1, 1.122462048309373, 1.2599210498948732, 1.3348398541700344, 1.681792830507429, 1.7817974362806785]
  • Corresponds to: S R G m D n (komal Ma, komal Ni, no Pa)

Loaded raga ratios (incorrect):

  • 7 ratios: [1.0, 1.122462048309373, 1.2599210498948732, 1.4142135623730951, 1.4983070768766815, 1.681792830507429, 1.8877486253633868]
  • Corresponds to: S R G M P D N (shuddha Ma, Pa, shuddha Ni)

Key Transformations:

  • 1.3348398541700344 (komal Ma) → 1.4142135623730951 (shuddha Ma) + 1.4983070768766815 (Pa added)
  • 1.7817974362806785 (komal Ni) → 1.8877486253633868 (shuddha Ni)

Reproduction:

from idtap import SwaraClient, Piece

client = SwaraClient()
piece_data = client.get_piece('68a3a79fffd9b2d478ee11e8')

# Check raw stored data
stored_ratios = piece_data['raga']['ratios']
print(f'Stored ratios ({len(stored_ratios)}): {stored_ratios}')

# Check loaded raga
piece = Piece(piece_data)
loaded_ratios = piece.raga.ratios
print(f'Loaded ratios ({len(loaded_ratios)}): {loaded_ratios}')

# They should be identical but are not
assert stored_ratios == loaded_ratios, "Ratios don't match!"

Impact:

  • Pitch visualization shows wrong notes (e.g., Pa appears when it shouldn't)
  • Transcription analysis based on raga content is incorrect
  • Musical analysis and visualization tools produce inaccurate results

Potential Root Cause:
The issue likely occurs in the Raga constructor or initialization method where stored ratios are being processed/normalized rather than used as-is.

Environment:

  • Python idtap package (latest version)
  • Transcription ID: 68a3a79fffd9b2d478ee11e8
  • Raga: Rageshree

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions