In macOS, the sound effect of LibreOffice’s Presentation can be played below, but is it possible to do the same in Windows?
dir="/Applications/LibreOffice.app/Contents/Resources/gallery/sounds/"
35.times do |i|
sample dir,i
sleep sample_duration dir,i
end
Also, is it possible to know from Sonic Pi that the number of WAV files in the directory is 35?
Hi
I think that folder path ‘drag-n-drop’ is platform-agnostic. If LibreOffice is on your machine it lives in the Program Files folder (? many years since I used Windows). As long as the path exists and is correct. You can query the total number of files in any folder as follows:
samps = "/Users/brendan/Desktop/SONICPI-2024/samps4kevyn/blipz-7/"
names = Dir.children samps
puts names.length, 'files'
sleep 2
names.length.times do |i|
tick
puts names.look
sample samps,i
sleep 0.5
end
PD-Pi
1 Like
Thank you very much.
I understand Ruby’s Dir.children.
I do not have Windows at hand.
Could you please tell me the directory where the sound effects for Windows LibreOffice Presentation are located?
Sorry I don’t have Windows, or LibreOffice.
Thank you brendanmac.
Could someone please try this on LibreOffice on Windows?
dir="C:/Program Files/LibreOffice/share/gallery/sounds/"
works on Windows 11 with LibreOffice 7.6
1 Like
Another way to get the number of samples:
load_sample dir, lambda {|s| print s.length; s}
Also:
dir = "path"
dir.each do |i|
sample i
end
for i in dir
sample i
end
both work without knowing the size of dir
1 Like
Concision is the gold standard @Davids-Music-Lab
Thank you very much.
The second one did not work with the error
“undefined method `each’ for an instance of String (NoMethodError)”.
It worked when I modified it as follows.
(Dir.children dir).each do |i|
sample dir+i
sleep 0.1
end
for i in (Dir.children dir)
sample dir+i
sleep 0.1
end
Should work with this change:
dir = sample_paths "path"
Not sure what Sonic Pi itself has to do with it, but if the audio won’t play it’s usually the format rather than the file itself. Safe bet is wav or plain mp3, mono, normal sample rate. I’d check the clip plays outside the app first, then look at whether it’s set to start automatically. Is it one file failing or every sound you add?