Class SoundActor

    • Field Detail

      • bytesPerSample

        public SharedParameter bytesPerSample
        The number of bytes per sample. This is an integer that defaults to 2. This parameter is shared by all instances of this class and subclasses in the model, so changing it in one of those actors will cause it to change in all. An exception will be thrown if this parameter is set to an unsupported bit resolution. Changing the value of this parameter will have an effect only when the model is next initialized.
      • bufferSize

        public SharedParameter bufferSize
        The requested buffer size for transferring samples. This affects how far ahead of real time the model can get. A larger buffer size may limit the responsivity of the model because changes in the model will be heard only after the buffer has been flushed. This is an integer that defaults to 1024, representing a buffer with 1024 samples per channel. At an 8 kHz sample rate, this means a worst-case latency of about 1/8 seconds. This parameter is shared by all instances of this class and subclasses in the model, so changing it in one of those actors will cause it to change in all. Changing the value of this parameter will have an effect only when the model is next initialized.
      • channels

        public SharedParameter channels
        The number of audio channels. This is an integer that defaults to 1. This parameter is shared by all instances of this class and subclasses in the model, so changing it in one of those actors will cause it to change in all. An exception will be thrown if this parameter is set to an an unsupported channel number. Changing the value of this parameter will have an effect only when the model is next initialized.
      • sampleRate

        public SharedParameter sampleRate
        The sample rate in samples per second. This is an integer that defaults to 8000. This parameter is shared by all instances of this class and subclasses in the model, so changing it in one of those actors will cause it to change in all. An exception will be thrown if this parameter is set to an unsupported sample rate. Changing the value of this parameter will have an effect only when the model is next initialized.
      • _bytesPerSample

        protected int _bytesPerSample
        Value of the bytesPerSample parameter.
      • _bufferSize

        protected int _bufferSize
        The requested buffer size.
      • _channels

        protected int _channels
        The number of channels. Initialized from the channels parameter.
      • _sampleRate

        protected int _sampleRate
        The value of the sampleRate parameter.
      • _isExecuting

        protected boolean _isExecuting
        True if this actor is executing. Set to true by initialize(), set to false by wrapup().
    • Method Detail

      • _doubleArrayToByteArray

        protected void _doubleArrayToByteArray​(double[][] doubleArray,
                                               byte[] playbackData)
                                        throws java.lang.IllegalArgumentException
        Convert a double array of audio samples into a byte array of audio samples in linear signed PCM big endian format. The samples contained in doubleArray should be in the range (-1, 1). Samples outside this range will be hard clipped to the range (-1, 1). The result is put into the byte array given by playbackData, which is required to be big enough (or an ArrayIndexOutOfBounds exception will be thrown).
        Parameters:
        doubleArray - Two dimensional array holding audio samples. For each channel, m, doubleArray[m] is a single dimensional array containing samples for channel m. All channels are required to have the same number of samples, but this is not checked.
        playbackData - An array into which to put the results, which have bytes representing linear signed PCM big endian formatted audio data.
        Throws:
        java.lang.IllegalArgumentException - Not thrown in this base class.