COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :

Go Back   Cockos Incorporated Forums > Other Software Discussion > WDL users forum

Reply
 
Thread Tools Display Modes
Old 02-18-2018, 02:15 PM   #1
jan hase
Human being with feelings
 
Join Date: Jul 2017
Posts: 25
Default GetSamplePos() doesnt update every Sample

Hey guys,

i want to play a sound every 1/16 th. i got all the functions working for that, except, that i cant determine the correct SamplePos somehow.


assigning GetSamplePos() to a variable in ProcessDouble Replacing updates the variable only every nFrames, which causes the samplepos to overjump values: 0,32,64,96,....



Code:
void Reb::ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames)
{
	int SamplePos = GetSamplePos();
So i thought, okay i update SamplePos every Sample by assigning it from within the for loop in processdoublereplacing:

Code:
for (int s = 0; s < nFrames; ++s, ++in1, ++in2, ++out1, ++out2) {

SamplePos = GetSamplePos();
But that doesnt work somehow. the samplePos was still overjumping values.



So i thought alright, i update the SamplePos every nFrames from ProcessDoubleReplacing:
Code:
void Reb::ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames)
{
	int SamplePos = GetSamplePos();
and then sort of interpolate it with ++SamplePos in the For Loop:
Code:
for (int s = 0; s < nFrames; ++s, ++in1, ++in2, ++out1, ++out2) {
++SamplePos;
this increases the SamplePos with +1 which is what i wanted.


but when i want to play a sound every 1/16:

Code:
if(inBeatSync) {
PlaySaw = true;
}
inBeatSync turns true at the right SamplePos, but the SamplePos doesnt seem to be aligned with the actual samplePos that is played right now in the daw(bitwig in my case), the played Saw has always an offset to the grid.
this offset seems to change depening on what blocksize i select.


so my conclusion from that would be, that as midi notes need a midi queue the samplepos needs also a readjusting-offset manipulator in oder to be in sync with the daw samplepos - but i belive i overlooked something here, i hope you understand somewaht what i want and can help :-)
jan hase is offline   Reply With Quote
Old 02-19-2018, 12:44 AM   #2
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
Default

Maybe this will help:

https://forum.cockos.com/showthread.php?t=197352
Tale 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 07:04 AM.


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