Print Samplepath

Hi,
while i play a sample with
sample [“path”,“partOfFile”,“OtherPart”]
the terminal show things like:

sample “/path/”,
“file.wav”, {pan: 1, lpf: 100, hpf: 70, start: 0.2, amp: 0, pamp: 0.2, pamp_slide: 3}

Is it possible to get the filename and path, to write it to a file?
something like

log = "/path/logfile.log"
log.puts samplepath [“path”,“partOfFile”,“OtherPart”]
log.puts samplename [“path”,“partOfFile”,“OtherPart”]

Thank you

sample_paths might provide the path details you’re looking for, and you can use Ruby’s file I/O to write the file – parse the parts you’re interested in from sample_paths YOUR_SAMPLE into path_stuff in the sample code below…

path_stuff  = (sample_paths YOUR_SAMPLE)[0]
log = "/path/logfile.log"
x = File.open(log, "w")
x.puts path_stuff
x.close

hth,
d00d

Thank you!
With this, it is possible to print out the complete filepath.
Is it even possible to only print the filename? like “sound.wav”?

And a second question. (Sorry, but i am not so firm with Ruby and the Stringmanipulationthings…)
Is it possible to sorround the filepath with other text? like “The file sound.wav was played at time: 2:32, with amp 2 and a panning of -0.3”

Thanks!

sure, parsing strings works like this:

puts (sample_paths :ambi_choir)[0].split("/")[-1] # unqualified filename

you can generate sentence-like text strings by concatenating the bits together:

o = " orange"
puts "apple " + 36.to_s + o

perhaps sample_info provides some interesting sample details as well

Hi there,

simply use sample_info to get access to information about your sample :slight_smile:

s = sample_info :ambi_choir

puts s.path 
1 Like

Thank you very much!
Works great

1 Like

Sorry for my questions. But …
is there a way to print out the time?
When i play a sample the console puts out a
{run: 1, time:1.234}
Can i access this time value?
Thanks!

Yes, have a look at the lang documentation and the function: sample_duration.

sample_duration only gives me the duration of the current sample.
I want the complete past time… or i had to make an addition of all sleeps before the point i want to know the time…

Ah, i found:
puts rt(beat)
Seams to work.
Thanks!

sorry…no…does not do it right…

Oh, sorry. Well, yes, you probably will have to add up all your sleeps. At least I don’t know of any function in the core.

ok. thank you very much!

Found a way, even if its not very stable.
At the beginning i set
t = Time.now
and in the moment is use it i do
puts (Time.now - t)
But this gives slightly different values each time. But i can live with it :slight_smile:

See the fn vt - perhaps that’s what you’re looking for?