Comments (7)
@yoyoberenguer can you try using the 2.0.0 version of pianoputer and verify that this issue is fixed?
When I load in mono and stereo wavs into v2.0.0 I do not get the error in this issue so I think that this is fixed.
If I don't hear from you in the next week or two I will close this issue because I can't replicate it.
from pianoputer.
@spacether,
Good day to you.
First nice job on the last version 2.0.0 of pianoputer, it looks so much better.
I can confirm the issue persist with pygame version 2.0 (I am attaching the screenshots proving it and also the resolution that will make your life easier)
Here is the exception raised when loading (python 3.8 and pygame 2.0)
Here is the resolution (python 3.8 and pygame 2.0)
Resolution :
pygame.mixer.init(framerate_hz, BITS_32BIT, channels, allowedchanges=0)
Bear in mind that allowedchanges has been implemented recently in pygame and some older version will not recognized
this statement. In order to have a retro compatibility with odler version, you will have to implement some sort
of pygame.version detection and change accordingly (pianoputer won't throw an exception when using older version of
pygame < 2.0)
Also I didn't have time to look into the code but I noticed a bug in the method get_audio_data
try:
channels = len(audio_data[0])
except TypeError:
channels = 1
return audio_data, framerate_hz, channels
For a single track, the numpy.ndarray will by shape e.g (31728, ) and for a stereo (31728, 2)
The channel number is always referenced by the index 1 of the array (only for stereo or above) such as :
channels = audio_data[1]
index 0 is the samples data length
Your code above will always revert to a mono track and will never detect a stereo sound
(and this explained why you could not replicate the issue).
def is_valid_array(array_)->bool:
# DETERMINE IF THE ARRAY IS MONO OR STEREO AND RETURN TRUE IF VALID
# check the shape of an array
if hasatttr(array_, 'shape'):
if len(array_.shape) == 1: return True # mono sound
elif len(array_.shape) == 2:
if array_.shape[1] <=2: return True # stereo sound
else: return False
else: return False # more than 2 channel not implemented yet
else: return False # here Attribute Error, certainly not an ndarray type
from pianoputer.
Thank you for the explanation. What OS are you using?
Is this happening for stereo and mono files?
On MacOS I am unable to reproduce the issue.
On Windows10Pro I can reproduce the issue for mono files.
- the channel is being correctly detected as 1, mono wavs are produced, and something is going wrong with make_sound or the mixer. I am investigating it.
Good point about channels > 2, I should handle that use case.
from pianoputer.
Very weird, we are initializing the mixer with 1 channel for the mono wav file but on:
- windoes10pro pygame.mixer.get_init() returns (4800, -32, 2)
- and on macOs it reports (4800, -32, 1)
from pianoputer.
I have filed a pygame bug on this at pygame/pygame#2417
Edit: and I just closed the bug because passing in your suggested allowedchanges=0 solves it
from pianoputer.
A fix has been submitted for this issue at #22
from pianoputer.
@yoyoberenguer thank you for submitting this problem and letting us know how to fix it!
With v2.0.1 this issue should be resolved
On WIndows10Pro I ran the tests and verified that generating 1, 2, and 4 channel wav files works and that we no longer get this exception. If this problem is still occurring can you re-open this issue?
from pianoputer.
Related Issues (20)
- Nothing happens?
- not supporting two-channel wave files HOT 2
- value error HOT 6
- Direction on the input audio file for the azerty keyboard HOT 2
- Running in background HOT 4
- video effect when playing pianoputer HOT 3
- Can't save KB file HOT 2
- Publishing to pypi HOT 3
- Cannot build/run from source HOT 2
- AttributeError: 'Event' object has no attribute 'key' HOT 6
- 跪拜大佬牛年福星高照 (Kneel down to the big man, the year of the ox???) HOT 2
- 请教您键盘布局图是怎么绘制的?(Ask you how to draw the keyboard layout) HOT 7
- Can i install this with python 3.11? HOT 1
- License
- pitch_shift() takes 1 positional argument but 2 positional arguments (and 1 keyword-only argument) were given HOT 1
- hey why doesnt this thing get fixed
- Harpsichord more than a PianoForte?? HOT 2
- Unable to Transpond Sound File HOT 2
- Idea: Try mapping the keys to a stenography machine layout. HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pianoputer.