code: def preallocate_memory(self, capacity):
          
          if capacity < 0:
              raise ValueError(u"The capacity value cannot be negative")
          if self.__samples is None:
              self.log(u"Not initialized")
              self.__samples = numpy.zeros(capacity)
              self.__samples_length = 0
          else:
              self.log([u"Previous sample length was   (samples): %d", self.__samples_length])
              self.log([u"Previous sample capacity was (samples): %d", self.__samples_capacity])
              self.__samples = numpy.resize(self.__samples, capacity)
              self.__samples_length = min(self.__samples_length, capacity)
          self.__samples_capacity = capacity
          self.log([u"Current sample capacity is   (samples): %d", self.__samples_capacity])
docs: Preallocate memory to store audio samples,
          to avoid repeated new allocations and copies
          while performing several consecutive append operations.
  
          If ``self.__samples`` is not initialized,
          it will become an array of ``capacity`` zeros.
  
          If ``capacity`` is larger than the current capacity,
          the current ``self.__samples`` will be extended with zeros.
  
          If ``capacity`` is smaller than the current capacity,
          the first ``capacity`` values of ``self.__samples``
          will be retained.
  
          :param int capacity: the new capacity, in number of samples
          :raises: ValueError: if ``capacity`` is negative
  
          .. versionadded:: 1.5.0