@staticmethod<EOL><INDENT>def ads(**kwargs):<DEDENT>
<EOL>kwargs = kwargs.copy()<EOL>ADSFactory._check_normalize_args(kwargs)<EOL>block_dur = kwargs.pop("<STR_LIT>")<EOL>hop_dur = kwargs.pop("<STR_LIT>")<EOL>block_size = kwargs.pop("<STR_LIT>")<EOL>hop_size = kwargs.pop("<STR_LIT>")<EOL>max_time = kwargs.pop("<STR_LIT>")<EOL>audio_source = kwargs.pop("<STR_LIT>")<EOL>filename = kwargs.pop("<STR_LIT>")<EOL>data_buffer = kwargs.pop("<STR_LIT>")<EOL>record = kwargs.pop("<STR_LIT>")<EOL>if audio_source is not None:<EOL><INDENT>if (filename, data_buffer) != (None, None):<EOL><INDENT>raise Warning("<STR_LIT>")<EOL><DEDENT><DEDENT>elif filename is not None:<EOL><INDENT>if data_buffer is not None:<EOL><INDENT>raise Warning("<STR_LIT>")<EOL><DEDENT>audio_source = from_file(filename)<EOL><DEDENT>elif data_buffer is not None:<EOL><INDENT>audio_source = BufferAudioSource(data_buffer=data_buffer, **kwargs)<EOL><DEDENT>else:<EOL><INDENT>audio_source = PyAudioSource(**kwargs)<EOL><DEDENT>if block_dur is not None:<EOL><INDENT>if block_size is not None:<EOL><INDENT>raise DuplicateArgument("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>block_size = int(audio_source.get_sampling_rate() * block_dur)<EOL><DEDENT><DEDENT>elif block_size is None:<EOL><INDENT>block_size = int(audio_source.get_sampling_rate() / <NUM_LIT:100>)<EOL><DEDENT>ads = ADSFactory.AudioDataSource(audio_source=audio_source, block_size=block_size)<EOL>if max_time is not None:<EOL><INDENT>ads = ADSFactory.LimiterADS(ads=ads, max_time=max_time)<EOL><DEDENT>if record:<EOL><INDENT>ads = ADSFactory.RecorderADS(ads=ads)<EOL><DEDENT>if hop_dur is not None:<EOL><INDENT>if hop_size is not None:<EOL><INDENT>raise DuplicateArgument("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>hop_size = int(audio_source.get_sampling_rate() * hop_dur)<EOL><DEDENT><DEDENT>if hop_size is not None:<EOL><INDENT>if hop_size <= <NUM_LIT:0> or hop_size > block_size:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if hop_size < block_size:<EOL><INDENT>ads = ADSFactory.OverlapADS(ads=ads, hop_size=hop_size)<EOL><DEDENT><DEDENT>return ads<EOL>
Create an return an :class:`ADSFactory.AudioDataSource`. The type and behavior of the object is the result
of the supplied parameters.

:Parameters:

*No parameters* :  
   read audio data from the available built-in microphone with the default parameters.
   The returned :class:`ADSFactory.AudioDataSource` encapsulate an :class:`io.PyAudioSource` object and hence 
   it accepts the next four parameters are passed to use instead of their default values.

`sampling_rate`, `sr` : *(int)*
    number of samples per second. Default = 16000.

`sample_width`, `sw` : *(int)*
    number of bytes per sample (must be in (1, 2, 4)). Default = 2

`channels`, `ch` : *(int)*
    number of audio channels. Default = 1 (only this value is currently accepted)  

`frames_per_buffer`, `fpb` : *(int)*
    number of samples of PyAudio buffer. Default = 1024.

`audio_source`, `asrc` : an `AudioSource` object
    read data from this audio source

`filename`, `fn` : *(string)*
    build an `io.AudioSource` object using this file (currently only wave format is supported)

`data_buffer`, `db` : *(string)*
    build an `io.BufferAudioSource` using data in `data_buffer`. If this keyword is used,
    `sampling_rate`, `sample_width` and `channels` are passed to `io.BufferAudioSource`
    constructor and used instead of default values.

`max_time`, `mt` : *(float)*
    maximum time (in seconds) to read. Default behavior: read until there is no more data
    available. 

`record`, `rec` : *(bool)*
    save all read data in cache. Provide a navigable object which boasts a `rewind` method.
    Default = False.

`block_dur`, `bd` : *(float)*
    processing block duration in seconds. This represents the quantity of audio data to return 
    each time the :func:`read` method is invoked. If `block_dur` is 0.025 (i.e. 25 ms) and the sampling
    rate is 8000 and the sample width is 2 bytes, :func:`read` returns a buffer of 0.025 * 8000 * 2 = 400
    bytes at most. This parameter will be looked for (and used if available) before `block_size`.
    If neither parameter is given, `block_dur` will be set to 0.01 second (i.e. 10 ms)

`hop_dur`, `hd` : *(float)*
    quantity of data to skip from current processing window. if `hop_dur` is supplied then there
    will be an overlap of `block_dur` - `hop_dur` between two adjacent blocks. This
    parameter will be looked for (and used if available) before `hop_size`. If neither parameter
    is given, `hop_dur` will be set to `block_dur` which means that there will be no overlap
    between two consecutively read blocks.

`block_size`, `bs` : *(int)*
    number of samples to read each time the `read` method is called. Default: a block size
    that represents a window of 10ms, so for a sampling rate of 16000, the default `block_size`
    is 160 samples, for a rate of 44100, `block_size` = 441 samples, etc.

`hop_size`, `hs` : *(int)*
    determines the number of overlapping samples between two adjacent read windows. For a
    `hop_size` of value *N*, the overlap is `block_size` - *N*. Default : `hop_size` = `block_size`,
    means that there is no overlap.

:Returns:

An AudioDataSource object that has the desired features.

:Exampels:

1. **Create an AudioDataSource that reads data from the microphone (requires Pyaudio) with default audio parameters:**

.. code:: python

    from auditok import ADSFactory
    ads = ADSFactory.ads()
    ads.get_sampling_rate()
    16000
    ads.get_sample_width()
    2
    ads.get_channels()
    1

2. **Create an AudioDataSource that reads data from the microphone with a sampling rate of 48KHz:**

.. code:: python

    from auditok import ADSFactory
    ads = ADSFactory.ads(sr=48000)
    ads.get_sampling_rate()
    48000

3. **Create an AudioDataSource that reads data from a wave file:**

.. code:: python

    import auditok
    from auditok import ADSFactory
    ads = ADSFactory.ads(fn=auditok.dataset.was_der_mensch_saet_mono_44100_lead_trail_silence)
    ads.get_sampling_rate()
    44100
    ads.get_sample_width()
    2
    ads.get_channels()
    1

4. **Define size of read blocks as 20 ms**

.. code:: python

    import auditok
    from auditok import ADSFactory
    '''
    we know samling rate for previous file is 44100 samples/second
    so 10 ms are equivalent to 441 samples and 20 ms to 882
    '''
    block_size = 882
    ads = ADSFactory.ads(bs = 882, fn=auditok.dataset.was_der_mensch_saet_mono_44100_lead_trail_silence)
    ads.open()
    # read one block
    data = ads.read()
    ads.close()
    len(data)
    1764
    assert len(data) ==  ads.get_sample_width() * block_size

5. **Define block size as a duration (use block_dur or bd):**

.. code:: python

    import auditok
    from auditok import ADSFactory
    dur = 0.25 # second
    ads = ADSFactory.ads(bd = dur, fn=auditok.dataset.was_der_mensch_saet_mono_44100_lead_trail_silence)
    '''
    we know samling rate for previous file is 44100 samples/second
    for a block duration of 250 ms, block size should be 0.25 * 44100 = 11025
    '''
    ads.get_block_size()
    11025
    assert ads.get_block_size() ==  int(0.25 * 44100)
    ads.open()
    # read one block
    data = ads.read()
    ads.close()
    len(data)
    22050
    assert len(data) ==  ads.get_sample_width() * ads.get_block_size()

6. **Read overlapping blocks (one of hope_size, hs, hop_dur or hd > 0):**

For better readability we'd better use :class:`auditok.io.BufferAudioSource` with a string buffer:

.. code:: python

    import auditok
    from auditok import ADSFactory
    '''
    we supply a data beffer instead of a file (keyword 'bata_buffer' or 'db')
    sr : sampling rate = 16 samples/sec
    sw : sample width = 1 byte
    ch : channels = 1
    '''
    buffer = "abcdefghijklmnop" # 16 bytes = 1 second of data
    bd = 0.250 # block duration = 250 ms = 4 bytes
    hd = 0.125 # hop duration = 125 ms = 2 bytes 
    ads = ADSFactory.ads(db = "abcdefghijklmnop", bd = bd, hd = hd, sr = 16, sw = 1, ch = 1)
    ads.open()
    ads.read()
    'abcd'
    ads.read()
    'cdef'
    ads.read()
    'efgh'
    ads.read()
    'ghij'
    data = ads.read()
    assert data == 'ijkl'

7. **Limit amount of read data (use max_time or mt):**

.. code:: python

    '''
    We know audio file is larger than 2.25 seconds
    We want to read up to 2.25 seconds of audio data
    '''
    ads = ADSFactory.ads(mt = 2.25, fn=auditok.dataset.was_der_mensch_saet_mono_44100_lead_trail_silence)
    ads.open()
    data = []
    while True:
        d = ads.read()
        if d is None:
            break
        data.append(d)

    ads.close()
    data = b''.join(data)
    assert len(data) == int(ads.get_sampling_rate() * 2.25 * ads.get_sample_width() * ads.get_channels())