Coder Social home page Coder Social logo

value error about pianoputer HOT 6 CLOSED

dermitdog avatar dermitdog commented on June 6, 2024
value error

from pianoputer.

Comments (6)

dermitdog avatar dermitdog commented on June 6, 2024

I think I fixed the issue by using np.dot(), but in doing so I have found that this code is really not suited for newer versions of numpy/python. This sort of thing comes up multiple times.

from pianoputer.

Jholjhal avatar Jholjhal commented on June 6, 2024

I am also getting this error,
s1 = np.fft.fft(hanning_window * a1)
ValueError: operands could not be broadcast together with shapes (8192,) (8192,2)

from pianoputer.

yoyoberenguer avatar yoyoberenguer commented on June 6, 2024

This error is due to the fact that you are trying to broadcast and array shape (8192, 2) into a smaller array length 8192.
This scripts is coded for single track (mono sound track) sound and using a stereo sound track will raised
the below error message:
ValueError: operands could not be broadcast together with shapes (8192,) (8192,2)

To avoid this error, you will have to transform your sound into a mono track.
I would strongly recommend to use Audacity to load your sound file and export it as mono soundtrack .
(Audacity) : In the menu go to Tracks -> Mix -> Mix stereo Sound to Mono

When done, export your new sound as a WAV format and use it instead of Bowl.wav sound.

Keep in mind that the mixer has to be init accordingly
e.g
for mono sound : pygame.mixer.init(frequency, -16, 1, 2048)
for stereo sound : pygame.mixer.init(frequency, -16, 2, 2048)

Kind Regards

from pianoputer.

yoyoberenguer avatar yoyoberenguer commented on June 6, 2024

@spacether Good day to you, The above answer provide the explanation of this issue. The ValueError is raised when numpy is trying to broadcast two arrays with different sizes/dimensions.
This happen when a user is loading a stereo sound with the mono version of pianoputer.

If the user is loading a mono track sound then it will works fine for both versions of pianoputer (single & stereo mode).
The stereo version has a method that can check for the sound model (mono or stereo) and process the sound accordingly.

A permanent fix would be to implement a method that check the sound model and throw and explicit error message when user is loading a stereo sound and using the mono version of pianoputer.

Best wishes,

from pianoputer.

spacether avatar spacether commented on June 6, 2024

Thank you for that explanation. This issue should be fixed in the next version of pianoputer which handles mono and stereo in the same python file. That update is in a PR right now.

from pianoputer.

spacether avatar spacether commented on June 6, 2024

The above pitchshift code no longer exists in master branch so this issue should be resolved.
Testing with the included mono and stereo wav files verifies that this is resolved.

from pianoputer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.