Ask Your Question

# How can I immediately play a sample only once?

If I have a long sample, how do I trigger it to play immediately and only once?

This approach doesn't work well, because I can't control the timing of when it is fired:

d1 $sound "long_sample/100"  edit retag close merge delete ## 3 answers Sort by » oldest newest most voted If you have now defined (emacs has it, but I don't think the atom plugin does yet), this works:  d1$ now ~> (playFor 0 1 $sound "cp")  This is quantised to the next cycle though, is that what you want? more ## Comments 1 I think quantized to the next cycle would be just fine. It doesn't have to be instantaneous. ( 2016-06-13 09:28:01 -0500 )edit I once used this, as @yaxu suggested: runnow g d p' = do now <- g d$ (now + 0.1) ~> p'

oneshot g d p' = runnow g d $seqP [(0, 1, p')] oneshot' g d n p' = runnow g d$ seqP [(0, n, p')]


Usage would be like this:

let os = oneshot getNow

os d1 \$ sound "long_sample"


but the problem ist, that the latency until things are played, depends on ticksPerCycle which is 8 by default. To change the number of ticks per cycle you will have to edit Stream.hs in the tidal source.

This is essentially rotating the pattern to now (with a small offset to avoid skipping over) and then play the pattern via seqP just one time. If using emacs you can also use retrig for this.

The variant oneshot' plays the sample n times.

more

It's not really part of Tidal, and it's not great for just playing sounds, but another trick I use is that since everything you evaluate in Atom or Emacs gets sent to GHCi, you can use the shell escape command :! to run basically anything you want. If you've got SoX (or something similar) installed you can :!play path/to/file.wav, if you're on MacOS you can use the built-in voice synthesis with :!say "cheese" and so on...

more

## Stats

Asked: 2016-06-13 09:03:34 -0500

Seen: 927 times

Last updated: Jun 13 '16