228228
229229
230230
231- def read (file : FileDescriptorOrPath , frames : int = - 1 , start : int = 0 , stop : Optional [int ] = None ,
232- dtype : str = 'float64' , always_2d : bool = False ,
233- fill_value : Optional [float ] = None , out : Optional [AudioData ] = None ,
234- samplerate : Optional [int ] = None , channels : Optional [int ] = None ,
235- format : Optional [str ] = None , subtype : Optional [str ] = None ,
236- endian : Optional [str ] = None , closefd : bool = True ) -> Tuple [AudioData , int ]:
231+ def read (file : FileDescriptorOrPath , frames : int = - 1 , start : int = 0 , stop : Optional [int ]= None ,
232+ dtype : str = 'float64' , always_2d : bool = False ,
233+ fill_value : Optional [float ]= None , out : Optional [AudioData ]= None ,
234+ samplerate : Optional [int ]= None , channels : Optional [int ]= None ,
235+ format : Optional [str ]= None , subtype : Optional [str ]= None ,
236+ endian : Optional [str ]= None , closefd : bool = True ) -> Tuple [AudioData , int ]:
237237
238238 """Provide audio data from a sound file as NumPy array.
239239
@@ -327,10 +327,10 @@ def read(file: FileDescriptorOrPath, frames: int = -1, start: int = 0, stop: Opt
327327
328328
329329def write (file : FileDescriptorOrPath , data : AudioData , samplerate : int ,
330- subtype : Optional [str ] = None , endian : Optional [str ] = None ,
331- format : Optional [str ] = None , closefd : bool = True ,
332- compression_level : Optional [float ] = None ,
333- bitrate_mode : Optional [str ] = None ) -> None :
330+ subtype : Optional [str ]= None , endian : Optional [str ]= None ,
331+ format : Optional [str ]= None , closefd : bool = True ,
332+ compression_level : Optional [float ]= None ,
333+ bitrate_mode : Optional [str ]= None ) -> None :
334334 """Write data to a sound file.
335335
336336 .. note:: If *file* exists, it will be truncated and overwritten!
@@ -386,14 +386,14 @@ def write(file: FileDescriptorOrPath, data: AudioData, samplerate: int,
386386 f .write (data )
387387
388388
389- def blocks (file : FileDescriptorOrPath , blocksize : Optional [int ] = None ,
390- overlap : int = 0 , frames : int = - 1 , start : int = 0 ,
391- stop : Optional [int ] = None , dtype : str = 'float64' ,
392- always_2d : bool = False , fill_value : Optional [float ] = None ,
393- out : Optional [AudioData ] = None , samplerate : Optional [int ] = None ,
394- channels : Optional [int ] = None , format : Optional [str ] = None ,
395- subtype : Optional [str ] = None , endian : Optional [str ] = None ,
396- closefd : bool = True ) -> Generator [AudioData , None , None ]:
389+ def blocks (file : FileDescriptorOrPath , blocksize : Optional [int ]= None ,
390+ overlap : int = 0 , frames : int = - 1 , start : int = 0 ,
391+ stop : Optional [int ]= None , dtype : str = 'float64' ,
392+ always_2d : bool = False , fill_value : Optional [float ]= None ,
393+ out : Optional [AudioData ]= None , samplerate : Optional [int ]= None ,
394+ channels : Optional [int ]= None , format : Optional [str ]= None ,
395+ subtype : Optional [str ]= None , endian : Optional [str ]= None ,
396+ closefd : bool = True ) -> Generator [AudioData , None , None ]:
397397 """Return a generator for block-wise reading.
398398
399399 By default, iteration starts at the beginning and stops at the end
@@ -500,7 +500,7 @@ def __repr__(self):
500500 return info .format (self , indented_extra_info )
501501
502502
503- def info (file : FileDescriptorOrPath , verbose : bool = False ) -> _SoundFileInfo :
503+ def info (file : FileDescriptorOrPath , verbose : bool = False ) -> _SoundFileInfo :
504504 """Returns an object with information about a `SoundFile`.
505505
506506 Parameters
@@ -532,7 +532,7 @@ def available_formats() -> Dict[str, str]:
532532 _snd .SFC_GET_FORMAT_MAJOR ))
533533
534534
535- def available_subtypes (format : Optional [str ] = None ) -> Dict [str , str ]:
535+ def available_subtypes (format : Optional [str ]= None ) -> Dict [str , str ]:
536536 """Return a dictionary of available subtypes.
537537
538538 Parameters
@@ -555,8 +555,8 @@ def available_subtypes(format: Optional[str] = None) -> Dict[str, str]:
555555 if format is None or check_format (format , subtype ))
556556
557557
558- def check_format (format : str , subtype : Optional [str ] = None ,
559- endian : Optional [str ] = None ) -> bool :
558+ def check_format (format : str , subtype : Optional [str ]= None ,
559+ endian : Optional [str ]= None ) -> bool :
560560 """Check if the combination of format/subtype/endian is valid.
561561
562562 Examples
@@ -598,12 +598,12 @@ class SoundFile(object):
598598
599599 """
600600
601- def __init__ (self , file : FileDescriptorOrPath , mode : Optional [str ] = 'r' ,
602- samplerate : Optional [int ] = None , channels : Optional [int ] = None ,
603- subtype : Optional [str ] = None , endian : Optional [str ] = None ,
604- format : Optional [str ] = None , closefd : bool = True ,
605- compression_level : Optional [float ] = None ,
606- bitrate_mode : Optional [str ] = None ) -> None :
601+ def __init__ (self , file : FileDescriptorOrPath , mode : Optional [str ]= 'r' ,
602+ samplerate : Optional [int ]= None , channels : Optional [int ]= None ,
603+ subtype : Optional [str ]= None , endian : Optional [str ]= None ,
604+ format : Optional [str ]= None , closefd : bool = True ,
605+ compression_level : Optional [float ]= None ,
606+ bitrate_mode : Optional [str ]= None ) -> None :
607607 """Open a sound file.
608608
609609 If a file is opened with `mode` ``'r'`` (the default) or
@@ -836,7 +836,7 @@ def seekable(self) -> bool:
836836 """Return True if the file supports seeking."""
837837 return self ._info .seekable == _snd .SF_TRUE
838838
839- def seek (self , frames : int , whence : int = SEEK_SET ) -> int :
839+ def seek (self , frames : int , whence : int = SEEK_SET ) -> int :
840840 """Set the read/write position.
841841
842842 Parameters
@@ -882,9 +882,9 @@ def tell(self) -> int:
882882 return self .seek (0 , SEEK_CUR )
883883
884884
885- def read (self , frames : int = - 1 , dtype : str = 'float64' ,
886- always_2d : bool = False , fill_value : Optional [float ] = None ,
887- out : Optional [AudioData ] = None ) -> AudioData :
885+ def read (self , frames : int = - 1 , dtype : str = 'float64' ,
886+ always_2d : bool = False , fill_value : Optional [float ]= None ,
887+ out : Optional [AudioData ]= None ) -> AudioData :
888888 """Read from the file and return data as NumPy array.
889889
890890 Reads the given number of frames in the given data format
@@ -978,7 +978,7 @@ def read(self, frames: int = -1, dtype: str = 'float64',
978978 return out
979979
980980
981- def buffer_read (self , frames : int = - 1 , dtype : Optional [str ] = None ) -> memoryview :
981+ def buffer_read (self , frames : int = - 1 , dtype : Optional [str ]= None ) -> memoryview :
982982 """Read from the file and return data as buffer object.
983983
984984 Reads the given number of *frames* in the given data format
@@ -1127,10 +1127,10 @@ def buffer_write(self, data: Any, dtype: str) -> None:
11271127 assert written == frames
11281128 self ._update_frames (written )
11291129
1130- def blocks (self , blocksize : Optional [int ] = None , overlap : int = 0 ,
1131- frames : int = - 1 , dtype : str = 'float64' ,
1132- always_2d : bool = False , fill_value : Optional [float ] = None ,
1133- out : Optional [AudioData ] = None ) -> Generator [AudioData , None , None ]:
1130+ def blocks (self , blocksize : Optional [int ]= None , overlap : int = 0 ,
1131+ frames : int = - 1 , dtype : str = 'float64' ,
1132+ always_2d : bool = False , fill_value : Optional [float ]= None ,
1133+ out : Optional [AudioData ]= None ) -> Generator [AudioData , None , None ]:
11341134 """Return a generator for block-wise reading.
11351135
11361136 By default, the generator yields blocks of the given
@@ -1222,7 +1222,7 @@ def blocks(self, blocksize: Optional[int] = None, overlap: int = 0,
12221222 yield np .copy (block ) if copy_out else block
12231223 frames -= toread
12241224
1225- def truncate (self , frames : Optional [int ] = None ) -> None :
1225+ def truncate (self , frames : Optional [int ]= None ) -> None :
12261226 """Truncate the file to a given number of frames.
12271227
12281228 After this command, the read/write position will be at the new
@@ -1687,7 +1687,7 @@ class LibsndfileError(SoundFileRuntimeError):
16871687 code
16881688 libsndfile internal error number.
16891689 """
1690- def __init__ (self , code : int , prefix : str = "" ) -> None :
1690+ def __init__ (self , code : int , prefix : str = "" ) -> None :
16911691 SoundFileRuntimeError .__init__ (self , code , prefix )
16921692 self .code = code
16931693 self .prefix = prefix
0 commit comments