# Block-scoped sample-duration-based bpm modification

``

    with_sample_bpm  string_or_number (sample_name_or_duration)

Block-scoped modification of bpm so that sleeping for 1 will sleep for the duration of the sample.

Introduced in v2.1

## Options

num_beats: | The number of beats within the sample. By default this is 1.

## Examples

# Example 1
``
    live_loop :dnb do
      with_sample_bpm :loop_amen do
        sample :bass_dnb_f
        sample :loop_amen
        sleep 1
      end
    end
| ``
    #Set bpm based on :loop_amen duration

    #`sleep`ing for 1 sleeps for duration of :loop_amen
# Example 2
``
    live_loop :dnb do
      with_sample_bpm :loop_amen, num_beats: 4 do

        sample :bass_dnb_f
        sample :loop_amen
        sleep 4

      end
    end
| ``
    # Set bpm based on :loop_amen duration
    # but also specify that the sample duration
    # is actually 4 beats long.

    #`sleep`ing for 4 sleeps for duration of :loop_amen
    # as we specified that the sample consisted of
    # 4 beats