MCPcopy Create free account
hub / github.com/LibreVR/Revive / GetSample

Method GetSample

Revive/HapticsBuffer.cpp:40–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40float HapticsBuffer::GetSample()
41{
42 if (m_ConstantTimeout > 0)
43 {
44 m_ConstantMutex.lock();
45 float sample = m_Amplitude;
46 if (m_Frequency <= 0.5f && m_ConstantTimeout % 2 == 0)
47 sample = 0.0f;
48 m_ConstantMutex.unlock();
49
50 m_ConstantTimeout--;
51 return sample;
52 }
53
54 // We can't pass the write index, so the buffer is now empty
55 if (m_ReadIndex + 1 == m_WriteIndex)
56 return 0.0f;
57
58 // Index will overflow correctly, so no need for a modulo operator
59 uint8_t sample = m_Buffer[++m_ReadIndex];
60
61 return sample / 255.0f;
62}
63
64ovrHapticsPlaybackState HapticsBuffer::GetState()
65{

Callers 1

HapticsThreadMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected