Old 04-04-2019, 09:41 AM   #1
kartalex
Human being with feelings
 
Join Date: Dec 2015
Posts: 172
Default Optimal way to play sound from Lua Script?

Hi, guys!

What is the optimal way to play sound from Lua Script? Just for auditioning samples, like in browser. I know that Reaper's Lua is not for realtime work with sound, but... I think there are at least several methods.

For example - you can Load Sample to RS5k(using Lua), make track record and MIDI enabled and and send some notes to track with RS5k. But... It seems too complicated (((

Can you help me to find more suitable way?

Last edited by kartalex; 04-04-2019 at 02:46 PM.
kartalex is offline   Reply With Quote
Old 04-04-2019, 01:07 PM   #2
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

I don't recall there is any straight-forward way to do it from plain ReaScript.

You could suggest to Julian Sader, the developer of the js_ReaScriptAPI extension plugin, to add something for that. I might also myself look if there's some sensible way to add something into that plugin to allow that. Reaper does have a mechanism available for C++ extension plugins to play a PCM_source object (read, "audio file") into the main audio hardware output.

edit : I already got the playback working. But as usual, stopping (properly) is more complicated than anticipated...
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.

Last edited by Xenakios; 04-04-2019 at 01:49 PM.
Xenakios is offline   Reply With Quote
Old 04-04-2019, 03:51 PM   #3
kartalex
Human being with feelings
 
Join Date: Dec 2015
Posts: 172
Default

Quote:
Originally Posted by Xenakios View Post
I don't recall there is any straight-forward way to do it from plain ReaScript.

You could suggest to Julian Sader, the developer of the js_ReaScriptAPI extension plugin, to add something for that. I might also myself look if there's some sensible way to add something into that plugin to allow that. Reaper does have a mechanism available for C++ extension plugins to play a PCM_source object (read, "audio file") into the main audio hardware output.

edit : I already got the playback working. But as usual, stopping (properly) is more complicated than anticipated...
Cool, Xenakios!
I've posted the same question in Julian's thread, thank you!
kartalex is offline   Reply With Quote
Old 04-05-2019, 05:21 AM   #4
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Quote:
Originally Posted by Xenakios View Post
I don't recall there is any straight-forward way to do it from plain ReaScript.

You could suggest to Julian Sader, the developer of the js_ReaScriptAPI extension plugin, to add something for that. I might also myself look if there's some sensible way to add something into that plugin to allow that. Reaper does have a mechanism available for C++ extension plugins to play a PCM_source object (read, "audio file") into the main audio hardware output.

edit : I already got the playback working. But as usual, stopping (properly) is more complicated than anticipated...
Oh Boy..this would be awesome

We are in desperate need of such a function at Ultraschall
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 04-10-2019, 05:24 AM   #5
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

After doing some fixes in the extension code, it looks like cleaning up the playback objects might now be working, but I need to do some additional tests.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 04-10-2019, 02:16 PM   #6
kartalex
Human being with feelings
 
Join Date: Dec 2015
Posts: 172
Default

Quote:
Originally Posted by Xenakios View Post
After doing some fixes in the extension code, it looks like cleaning up the playback objects might now be working, but I need to do some additional tests.
Great news! Can't wait for it
kartalex is offline   Reply With Quote
Old 09-15-2020, 06:53 PM   #7
Nostrap
Human being with feelings
 
Join Date: Dec 2017
Posts: 179
Default

Anyone ever figure out how to play a sound from reascript?
Nostrap is offline   Reply With Quote
Old 09-15-2020, 07:25 PM   #8
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Install JS-extension: https://forum.cockos.com/showthread.php?t=212174

which gives you access to the functions

https://mespotin.uber.space/Ultrasch...tSourcePreview

to play a sample and

https://mespotin.uber.space/Ultrasch...pSourcePreview

to stop it.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 09-16-2020, 10:02 AM   #9
Nostrap
Human being with feelings
 
Join Date: Dec 2017
Posts: 179
Default

Thanks this is amazing!
Nostrap is offline   Reply With Quote
Old 09-17-2020, 12:25 AM   #10
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 565
Default

Is it able to preview a file not start from the beginning?
dsyrock is offline   Reply With Quote
Old 09-17-2020, 02:18 AM   #11
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Nope.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 01:26 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.