Skip to content

question about example #240

@gucio321

Description

@gucio321

Hi there!

context

I'm working on a morse code generator app. I've based my code on oto's example (sine wave is exactly what I needed).

My issue

After implementing the code in my app I noticed 2 issues:

  • (*SinWave).Read sometimes panics with index out of range [:-3XXXX] or, sometimes sound was corrupted (longer and glitchy). I managed to fix that by adding sync.Mutex (For some reason Read was called twice by oto, idk why).
  • the other issue may be specific to my app, where it must not appear, and may be wanted here in example to keep it as simple as possible: when the sound starts playing and when it ends, you can hear a "tap". It is a hardware thing imo. It could be removed by the following:
                b := int16(math.Sin(2*math.Pi*float64(p)/length) * 0.3 * max)

                if p <= stuckReduction {
                        b = int16(float64(p) / (stuckReduction) * math.Sin(2*math.Pi*float64(p)/length) * 0.3 *
                }

stuckReduction is a constant, which for me is 300 but could be reducd probably to about 100/200.

Let me know if my notes are worth adding to the example 😄.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions