Old 10-12-2018, 01:35 AM   #1
Cedrik0s
Human being with feelings
 
Join Date: Oct 2014
Posts: 77
Default Create audio item and file

Hi there.

I have seen have to create a PCM_source from a file, access samples etc...
(using Python on Windows)

I was wondering if I can do the other way around: can I create an item programmatically, directly giving it a buffer of audio samples, and use Reaper to make this into a wav file?

Thanks,
Cheers
Cedrik0s is offline   Reply With Quote
Old 10-12-2018, 02:33 AM   #2
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

I think you are asking about either of these things :

1) Create a PCM_sink in order to write audio files. (PCM_sink is Reaper's object type for writing audio files.)

or

2) Create a custom PCM_source that generates audio programmatically and would be used as an audio source for a media item take.

These can't currently be done with ReaScript. They can be achieved with C++ extension plugins, though.
__________________
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 10-12-2018, 05:54 AM   #3
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,629
Default

Would it be possible and somehow useable to expose them to ReaScript?
Or is ReaScript not suitable for usage of them?
__________________
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 10-12-2018, 06:12 AM   #4
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by mespotine View Post
Would it be possible and somehow useable to expose them to ReaScript?
Or is ReaScript not suitable for usage of them?
Exposing the PCM_sinks should be fairly easily possible.

Allowing ReaScripts to implement custom PCM_sources is trickier because Lua and Python are not real time safe. (Heap allocations, garbage collection...) That said, Reaper does have media source buffering so maybe it would work well enough most of the time anyway.

Eel ReaScript might not have the dynamic memory and garbage collection problem, but I wouldn't personally like a scripting feature that is only available from Eel code.
__________________
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 10-15-2018, 02:20 AM   #5
Cedrik0s
Human being with feelings
 
Join Date: Oct 2014
Posts: 77
Default

Sorry for my delayed answer.
Thanks guys for your answers.

Quote:
Originally Posted by Xenakios View Post
I think you are asking about either of these things :

1) Create a PCM_sink in order to write audio files. (PCM_sink is Reaper's object type for writing audio files.)

or

2) Create a custom PCM_source that generates audio programmatically and would be used as an audio source for a media item take.

These can't currently be done with ReaScript. They can be achieved with C++ extension plugins, though.
I see. It's a pity. It would have been handy to generate some file programmatically at times.

I guess I'll have a look at the C++ extension plugins some time.

Thanks,
Cheers
Cedrik0s is offline   Reply With Quote
Old 10-15-2018, 02:56 AM   #6
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by Cedrik0s View Post
I guess I'll have a look at the C++ extension plugins some time.
I have added support for writing WAV audio files with ReaScript into Julian Sander's extension plugin. https://forum.cockos.com/showthread.php?t=212174

However, the current binaries of the extension have a bug I've just hopefully fixed, so you should wait until Julian has accepted my fix and the new binaries have been built and uploaded.

Implementing support for custom PCM_sources implemented in ReaScript code is not currently possible I think...
__________________
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 10-15-2018, 03:46 AM   #7
Cedrik0s
Human being with feelings
 
Join Date: Oct 2014
Posts: 77
Default

Quote:
Originally Posted by Xenakios View Post
I have added support for writing WAV audio files with ReaScript into Julian Sander's extension plugin. https://forum.cockos.com/showthread.php?t=212174

However, the current binaries of the extension have a bug I've just hopefully fixed, so you should wait until Julian has accepted my fix and the new binaries have been built and uploaded.

Implementing support for custom PCM_sources implemented in ReaScript code is not currently possible I think...
Very interesting!
I'll check that extension. Thanks a lot!
(at the moment I am only interested in sinks anyway, not in sources)

Cheers
Cedrik0s 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 08:42 AM.


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