Skip to content

Conversation

@thorwhalen
Copy link
Contributor

See issue #95

@thorwhalen
Copy link
Contributor Author

Made this PR which addresses the comments made in issue #95, and also includes my solution for #94 (simply adding a method to play in notebooks, with a notebook appropriate tool (IPython.display.Audio object), which I also included in a different PR in case you only wanted that.

I only changed the series.py module:
There's what I discussed in issue #95, but also minor spelling errors (e.g. "The data column mapped to pitch when sonifying." instead of "The data column mappend to putch when sonifying.").

Tests pass, and I (think) I kept the same behavior as before, even though, I'm not sure this was intended.
Most notable example, see that the (hardcoded) envelop configurations are different whether you are playing the file, or your writing it to a file. My knee-jerk reaction is to think this is an oversight, since I guess a user might be surprised that the sound they heard with play is different than the one they write to a file, and then play from there (namely, the attack of the notes are slower in the file version).

One of the thing I wanted to do is un-hardcode this aspect of the code, centralizing it. Why? Two good reasons:

  • So that these misalignments can't happen (since play, write etc. will be using the SAME configurations by definition).
  • So that the user has a way to change these without changing the code: Though if we really want this configuration feature to be clean, we should make a method for this, or include an audio_config argument in the init. Write now, I'm just "open-closing" it so that the possibility is there.

I would have liked to just say:

AUDIO_CONFIG = (
    (0, 0),  # Start at silence
    (0.01, 1),  # Quick attack to full volume
    ("dur-0.1", 1),  # Hold at full volume until near end
    ("dur-0.05", 0.5),  # Start release
    ("dur-0.005", 0),  # End with silence
)

(or actually, would prefer to make that a namedtuple, but wanted to keep it closer to the existing code).

Since play and write were misaligned, to keep the current behavior, I needed to do this instead:

    AUDIO_CONFIG = {
        # Envelope parameters for playback
        "play_envelope": [
            (0, 0),  # Start at silence
            (0.01, 1),  # Quick attack to full volume
            ("dur-0.1", 1),  # Hold at full volume until near end
            ("dur-0.05", 0.5),  # Start release
            ("dur-0.005", 0),  # End with silence
        ],
        # Envelope parameters for writing to file
        "write_envelope": [
            (0, 0),  # Start at silence
            (0.1, 1),  # Slower attack for files
            ("dur-0.1", 1),  # Hold at full volume until near end
            ("dur-0.05", 0.5),  # Start release
            ("dur-0.005", 0),  # End with silence
        ],
    }

so if this misalignment wasn't on purpose, I suggest you use a single audio config instead.

@thorwhalen
Copy link
Contributor Author

I updated this my branch to rename play_notebook to play_in_notebook, as requested by @scfleming in this comment.

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.

1 participant