Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CF_CreatePreview: When changing the pitch, the sound breaks off in different places. #1854

Open
cool9-MK opened this issue Feb 26, 2024 · 2 comments · Fixed by #1861
Open
Assignees
Labels

Comments

@cool9-MK
Copy link

Example code:

local mode = 9
local submode = 0

local source  = reaper.PCM_Source_CreateFromFile('C:/untitled.wav')
local preview = reaper.CF_CreatePreview(source)

reaper.CF_Preview_SetValue(preview, "D_VOLUME", 1)
reaper.CF_Preview_SetValue(preview, "D_PITCH", 2) -- the pitch is changed to produce a click
reaper.CF_Preview_SetValue(preview, 'B_PPITCH', 0)
reaper.CF_Preview_SetValue(preview, "I_PITCHMODE", mode<<16|submode)

local track = reaper.GetSelectedTrack(0, 0)
reaper.CF_Preview_SetOutputTrack(preview, nil, track)

reaper.CF_Preview_Play(preview) -- after configuring the preview

Results (From top to bottom: Original file, D_PITCH = 0, D_PITCH = -1, D_PITCH = 2):
изображение

@cfillion
Copy link
Member

cfillion commented Mar 12, 2024

Thanks, I think I found the problem. Could you give the builds in the PR above a try?

(By the way the snippet above is missing PCM_Source_Destroy(source))

@cool9-MK
Copy link
Author

Thank you!
I tested it. It got much better! The wave almost always has the correct duration.
But now at the end of the sound there is a small artifact that looks like a distorted waveform. This isn't a big problem when played back alone, but it is a problem when played back on loop: even a waveform with a perfect start and end will sound stuttered when played back on loop, stuttering at the end each time.
Also, I discovered two modes in which the waveform breaks off as before: these are Simple Windowed (mode = 2) and ReaReaRea (mode = 15). (Assuming the "mode" locale from the Example code)

Screenshot of my testing results:
Results (From top to bottom: Original file, mode = 9, mode = 2, mode = 15):
изображение

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants