Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Rivill
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MINT
Rivill
Commits
0797b5b3
Commit
0797b5b3
authored
1 year ago
by
Florent Berthaut
Browse files
Options
Downloads
Patches
Plain Diff
Fix audio uniforms
parent
e77d86d0
No related branches found
No related tags found
No related merge requests found
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/audio/AudioManager.cpp
+92
-92
92 additions, 92 deletions
src/audio/AudioManager.cpp
src/modules/ProjectorModule.cpp
+593
-593
593 additions, 593 deletions
src/modules/ProjectorModule.cpp
src/shaders/render43.fs
+497
-497
497 additions, 497 deletions
src/shaders/render43.fs
with
1182 additions
and
1182 deletions
src/audio/AudioManager.cpp
+
92
−
92
View file @
0797b5b3
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
void
*
audioThreadFunction
(
void
*
pvParam
)
{
void
*
audioThreadFunction
(
void
*
pvParam
)
{
AudioManager
*
pThis
=
(
AudioManager
*
)
pvParam
;
AudioManager
*
pThis
=
(
AudioManager
*
)
pvParam
;
pThis
->
startStream
();
pThis
->
startStream
();
return
0
;
return
0
;
}
}
...
@@ -48,116 +48,116 @@ int AudioManager::getMixSize(){
...
@@ -48,116 +48,116 @@ int AudioManager::getMixSize(){
}
}
int
AudioManager
::
rtaudio_callback
(
void
*
outbuf
,
void
*
inbuf
,
unsigned
int
nFrames
,
int
AudioManager
::
rtaudio_callback
(
void
*
outbuf
,
void
*
inbuf
,
unsigned
int
nFrames
,
double
streamtime
,
RtAudioStreamStatus
status
,
void
*
userdata
)
{
double
streamtime
,
RtAudioStreamStatus
status
,
void
*
userdata
)
{
(
void
)
inbuf
;
(
void
)
inbuf
;
float
*
buf
=
(
float
*
)
outbuf
;
float
*
buf
=
(
float
*
)
outbuf
;
AudioManager
::
CallbackData
*
data
=
(
AudioManager
::
CallbackData
*
)
userdata
;
AudioManager
::
CallbackData
*
data
=
(
AudioManager
::
CallbackData
*
)
userdata
;
//if we've reached the first buffer again, retrieve values from the ring
//if we've reached the first buffer again, retrieve values from the ring
if
(
data
->
bufCounter
==
0
)
{
if
(
data
->
bufCounter
==
0
)
{
if
(
ringbuffer_read_space
(
data
->
ringBuffer
)
>=
data
->
bufSize
)
{
if
(
ringbuffer_read_space
(
data
->
ringBuffer
)
>=
data
->
bufSize
)
{
//read all the audio values
//read all the audio values
ringbuffer_read
(
data
->
ringBuffer
,
data
->
buffer
,
data
->
bufSize
);
ringbuffer_read
(
data
->
ringBuffer
,
data
->
buffer
,
data
->
bufSize
);
//mix the first buffer with the last of the previous
//mix the first buffer with the last of the previous
float
step
=
1.0
/
float
(
nFrames
);
float
step
=
1.0
/
float
(
nFrames
);
float
cnt
=
0.0
;
float
cnt
=
0.0
;
for
(
int
i
=
0
;
i
<
nFrames
;
++
i
)
{
for
(
int
i
=
0
;
i
<
nFrames
;
++
i
)
{
buf
[
i
*
2
]
=
data
->
buffer
[
i
]
*
cnt
+
data
->
mixBuffer
[
i
]
*
(
1.0
-
cnt
);
buf
[
i
*
2
]
=
data
->
buffer
[
i
]
*
cnt
+
data
->
mixBuffer
[
i
]
*
(
1.0
-
cnt
);
buf
[
i
*
2
+
1
]
=
buf
[
i
*
2
];
buf
[
i
*
2
+
1
]
=
buf
[
i
*
2
];
cnt
+=
step
;
cnt
+=
step
;
}
}
//save the last buffer for crossfading
//save the last buffer for crossfading
memcpy
(
&
data
->
mixBuffer
[
0
],
memcpy
(
&
data
->
mixBuffer
[
0
],
data
->
buffer
+
(
data
->
bufSize
-
data
->
mixSize
),
data
->
buffer
+
(
data
->
bufSize
-
data
->
mixSize
),
data
->
mixSize
*
sizeof
(
float
));
data
->
mixSize
*
sizeof
(
float
));
}
}
else
{
else
{
memset
(
buf
,
0
,
nFrames
*
data
->
nChannel
*
sizeof
(
float
));
memset
(
buf
,
0
,
nFrames
*
data
->
nChannel
*
sizeof
(
float
));
memset
(
data
->
buffer
,
0
,
data
->
bufSize
*
sizeof
(
float
));
memset
(
data
->
buffer
,
0
,
data
->
bufSize
*
sizeof
(
float
));
memset
(
data
->
mixBuffer
,
0
,
nFrames
*
sizeof
(
float
));
memset
(
data
->
mixBuffer
,
0
,
nFrames
*
sizeof
(
float
));
//cout<<"AudioManager : Could not read buffer"<<endl;
//cout<<"AudioManager : Could not read buffer"<<endl;
}
}
}
}
else
{
else
{
//read the next buffer
//read the next buffer
for
(
int
i
=
0
;
i
<
nFrames
;
++
i
)
{
for
(
int
i
=
0
;
i
<
nFrames
;
++
i
)
{
buf
[
i
*
2
]
=
data
->
buffer
[
data
->
bufCounter
*
nFrames
+
i
];
buf
[
i
*
2
]
=
data
->
buffer
[
data
->
bufCounter
*
nFrames
+
i
];
buf
[
i
*
2
+
1
]
=
buf
[
i
*
2
];
buf
[
i
*
2
+
1
]
=
buf
[
i
*
2
];
}
}
}
}
//move to the next buffer
//move to the next buffer
data
->
bufCounter
=
(
data
->
bufCounter
+
1
)
%
(
data
->
nbBufs
-
1
);
data
->
bufCounter
=
(
data
->
bufCounter
+
1
)
%
(
data
->
nbBufs
-
1
);
return
0
;
return
0
;
}
}
AudioManager
::
AudioManager
()
{
AudioManager
::
AudioManager
()
{
m_init
=
false
;
m_init
=
false
;
}
}
void
AudioManager
::
init
()
{
void
AudioManager
::
init
()
{
//m_rtAudio = new RtAudio(RtAudio::LINUX_PULSE);
//m_rtAudio = new RtAudio(RtAudio::LINUX_PULSE);
m_rtAudio
=
new
RtAudio
(
RtAudio
::
UNIX_JACK
);
m_rtAudio
=
new
RtAudio
(
RtAudio
::
UNIX_JACK
);
param
=
new
RtAudio
::
StreamParameters
();
param
=
new
RtAudio
::
StreamParameters
();
param
->
deviceId
=
m_rtAudio
->
getDefaultOutputDevice
();
param
->
deviceId
=
m_rtAudio
->
getDefaultOutputDevice
();
param
->
nChannels
=
2
;
param
->
nChannels
=
2
;
options
=
new
RtAudio
::
StreamOptions
();
options
=
new
RtAudio
::
StreamOptions
();
options
->
streamName
=
"Rivill"
;
options
->
streamName
=
"Rivill"
;
data
.
nRate
=
m_rtAudio
->
getDeviceInfo
(
param
->
deviceId
).
preferredSampleRate
;
data
.
nRate
=
m_rtAudio
->
getDeviceInfo
(
param
->
deviceId
).
preferredSampleRate
;
m_rtBufSize
=
1024
;
m_rtBufSize
=
1024
;
bool
init
=
true
;
bool
init
=
true
;
try
{
try
{
m_rtAudio
->
openStream
(
param
,
NULL
,
RTAUDIO_FLOAT32
,
data
.
nRate
,
m_rtAudio
->
openStream
(
param
,
NULL
,
RTAUDIO_FLOAT32
,
data
.
nRate
,
&
m_rtBufSize
,
&
m_rtBufSize
,
AudioManager
::
rtaudio_callback
,
&
data
,
options
);
AudioManager
::
rtaudio_callback
,
&
data
,
options
);
}
}
catch
(
const
exception
&
e
)
{
catch
(
const
exception
&
e
)
{
init
=
false
;
init
=
false
;
}
}
if
(
init
)
{
if
(
init
)
{
int
nbBufs
=
5
;
int
nbBufs
=
6
-
m_rtBufSize
/
256
;
m_bufSize
=
m_rtBufSize
*
nbBufs
;
m_bufSize
=
m_rtBufSize
*
nbBufs
;
data
.
ringBuffer
=
ringbuffer_create
(
m_bufSize
*
3
);
data
.
ringBuffer
=
ringbuffer_create
(
m_bufSize
*
3
);
data
.
nChannel
=
param
->
nChannels
;
data
.
nChannel
=
param
->
nChannels
;
data
.
bufSize
=
m_bufSize
;
data
.
bufSize
=
m_bufSize
;
data
.
buffer
=
new
float
[
m_bufSize
];
data
.
buffer
=
new
float
[
m_bufSize
];
data
.
nbBufs
=
nbBufs
;
data
.
nbBufs
=
nbBufs
;
data
.
bufCounter
=
0
;
data
.
bufCounter
=
0
;
memset
(
&
data
.
buffer
[
0
],
0
,
data
.
bufSize
*
sizeof
(
float
));
memset
(
&
data
.
buffer
[
0
],
0
,
data
.
bufSize
*
sizeof
(
float
));
data
.
mixSize
=
m_rtBufSize
;
data
.
mixSize
=
m_rtBufSize
;
data
.
mixBuffer
=
new
float
[
data
.
mixSize
];
data
.
mixBuffer
=
new
float
[
data
.
mixSize
];
memset
(
&
data
.
mixBuffer
[
0
],
0
,
data
.
mixSize
*
sizeof
(
float
));
memset
(
&
data
.
mixBuffer
[
0
],
0
,
data
.
mixSize
*
sizeof
(
float
));
m_thread
=
new
std
::
thread
(
audioThreadFunction
,
this
);
m_thread
=
new
std
::
thread
(
audioThreadFunction
,
this
);
m_init
=
true
;
m_init
=
true
;
}
}
}
}
bool
AudioManager
::
changeBuf
(
float
*
outputBuf
,
float
maxSinValue
)
{
bool
AudioManager
::
changeBuf
(
float
*
outputBuf
,
float
maxSinValue
)
{
if
(
m_init
)
{
if
(
m_init
)
{
//check if there is space to write the new values
//check if there is space to write the new values
size_t
write_space
=
ringbuffer_write_space
(
data
.
ringBuffer
);
size_t
write_space
=
ringbuffer_write_space
(
data
.
ringBuffer
);
if
(
write_space
>=
m_bufSize
)
{
if
(
write_space
>=
m_bufSize
)
{
//write all data to the ringbuffer
//write all data to the ringbuffer
ringbuffer_write
(
data
.
ringBuffer
,
outputBuf
,
data
.
bufSize
);
ringbuffer_write
(
data
.
ringBuffer
,
outputBuf
,
data
.
bufSize
);
return
true
;
return
true
;
}
}
else
{
else
{
//cout<<"AudioManager : Could not write buffer"<<endl;
//cout<<"AudioManager : Could not write buffer"<<endl;
}
}
}
}
return
false
;
return
false
;
}
}
This diff is collapsed.
Click to expand it.
src/modules/ProjectorModule.cpp
+
593
−
593
View file @
0797b5b3
This diff is collapsed.
Click to expand it.
src/shaders/render43.fs
+
497
−
497
View file @
0797b5b3
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment