Ask Your Question

How can I immediately play a sample only once?

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

kindohm gravatar image

updated 2016-06-13 09:04:10 -0500

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 flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted

answered 2016-06-13 09:19:32 -0500

yaxu gravatar image

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?

edit flag offensive delete link more



I think quantized to the next cycle would be just fine. It doesn't have to be instantaneous.

kindohm gravatar imagekindohm ( 2016-06-13 09:28:01 -0500 )edit

answered 2016-06-13 09:17:07 -0500

lennart gravatar image

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.

edit flag offensive delete link more

answered 2016-06-13 11:19:30 -0500

bgold gravatar image

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...

edit flag offensive delete link more

Question Tools

1 follower


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

Seen: 927 times

Last updated: Jun 13 '16