Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Report] soundcard with synthplayer module on macos. #179

Open
noboruatkek opened this issue May 15, 2024 · 1 comment
Open

[Report] soundcard with synthplayer module on macos. #179

noboruatkek opened this issue May 15, 2024 · 1 comment

Comments

@noboruatkek
Copy link

I test an example script for synthplayer module, examples/synth_demo.py, on macos, then I got the following message:

File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/soundcard/coreaudio.py", line 464, in init
raise TypeError("blocksize must be between {} and {}"
TypeError: blocksize must be between 14.0 and 512

After studying soundcard/synthplaer, I noticed that maxblcoksize of AudioUnit may be changed internally. So that requested blocksize may exceed the maxblocksize, then we will get the error message above. I modified soundcard/coreaudio.py slightly, shown below:

@@ -458,12 +458,14 @@
# there are two maximum block sizes for some reason:
maxblocksize = min(self.blocksizerange[1],
self.maxblocksize)

  •    if self.blocksizerange[0] <= blocksize <= maxblocksize:
    
  •    if self.blocksizerange[0] <= blocksize <= self.blocksizerange[1]:
    
  •        if maxblocksize < blocksize: self.maxblocksize=blocksize
           self.blocksize = blocksize
       else:
    
  •        raise TypeError("blocksize must be between {} and {}"
    
  •                        .format(self.blocksizerange[0],
    
  •                                maxblocksize))
    
  •        raise TypeError("blocksize({}) must be between {} and {}"
    
  •                        .format(blocksize, self.blocksizerange[0],
    
  •                                self.blocksizerange[1]))
    
       if isinstance(channels, collections.abc.Iterable):
           if iotype == 'output':
    

@@ -585,6 +587,13 @@
_cac.kAudioUnitScope_Global, 0, "UInt32")
assert maxblocksize
return maxblocksize
+

  • @maxblocksize.setter
  • def maxblocksize(self, newblocksize):
  •    data = _ffi.new("UInt32*", newblocksize)
    
  •    self._set_property(
    
  •        _cac.kAudioUnitProperty_MaximumFramesPerSlice,
    
  •        _cac.kAudioUnitScope_Global, 0, data)
    

Now I can run the synthplayer example script, synth_demo.py, with some parameter adjustment( params.norm_frames_per_chunk=1024) .

Thank you very much for make the nice program available to u.s.

@bastibe
Copy link
Owner

bastibe commented May 16, 2024

Please reformat so it makes sense on Github.

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

No branches or pull requests

2 participants