Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Gdpd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
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
IVMI
Gdpd
Commits
79dfff51
Commit
79dfff51
authored
5 years ago
by
BERTHAUT Florent
Browse files
Options
Downloads
Patches
Plain Diff
Fixed printing messages from pd
parent
50c1578f
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/gdpd.cpp
+20
-17
20 additions, 17 deletions
src/gdpd.cpp
src/gdpd.hpp
+8
-1
8 additions, 1 deletion
src/gdpd.hpp
src/rtaudio/RtAudio.os
+0
-0
0 additions, 0 deletions
src/rtaudio/RtAudio.os
with
28 additions
and
18 deletions
src/gdpd.cpp
+
20
−
17
View file @
79dfff51
...
...
@@ -12,17 +12,21 @@ void Gdpd::_register_methods() {
register_method
(
"add_symbol"
,
&
Gdpd
::
add_symbol
);
register_method
(
"add_float"
,
&
Gdpd
::
add_float
);
register_method
(
"finish_list"
,
&
Gdpd
::
finish_list
);
register_method
(
"set_volume"
,
&
Gdpd
::
set_volume
);
}
int
Gdpd
::
audioCallback
(
void
*
outputBuffer
,
void
*
inputBuffer
,
unsigned
int
nBufferFrames
,
double
streamTime
,
RtAudioStreamStatus
status
,
void
*
userData
){
// pass audio samples to/from libpd
int
ticks
=
nBufferFrames
/
64
;
libpd_process_float
(
ticks
,
(
float
*
)
inputBuffer
,
(
float
*
)
outputBuffer
);
return
0
;
Gdpd
*
gdpd
=
static_cast
<
Gdpd
*>
(
userData
);
int
ticks
=
nBufferFrames
/
64
;
gdpd
->
m_pd
.
processFloat
(
ticks
,
(
float
*
)
inputBuffer
,
(
float
*
)
outputBuffer
);
gdpd
->
m_pd
.
receiveMessages
();
for
(
int
b
=
0
;
b
<
nBufferFrames
;
++
b
)
{
((
float
*
)
outputBuffer
)[
b
]
*=
gdpd
->
get_volume
();
}
return
0
;
}
Gdpd
::
Gdpd
()
{
Gdpd
::
Gdpd
()
:
m_vol
(
1
)
{
}
void
Gdpd
::
_init
()
{
...
...
@@ -30,22 +34,16 @@ void Gdpd::_init() {
}
Gdpd
::~
Gdpd
()
{
// add your cleanup here
}
int
Gdpd
::
init
(
int
nbInputs
,
int
nbOutputs
,
int
sampleRate
)
{
if
(
!
m_pd
.
init
(
nbInputs
,
nbOutputs
,
sampleRate
,
true
))
{
Godot
::
print
(
"GDPD : Error starting libpd"
);
return
1
;
}
/*
int bufsize = 128;
m_inBuf = new float[bufsize * nbInputs];
m_outBuf = new float[bufsize * nbOutputs];
*/
libpd_set_verbose
(
1
);
//create message array
m_messages
=
new
Array
();
...
...
@@ -79,7 +77,7 @@ int Gdpd::init(int nbInputs, int nbOutputs, int sampleRate) {
try
{
m_audio
.
openStream
(
&
outParams
,
&
inParams
,
RTAUDIO_FLOAT32
,
sr
,
&
m_bufferFrames
,
&
audioCallback
,
&
m_pd
,
&
options
);
this
,
&
options
);
m_audio
.
startStream
();
}
catch
(
RtAudioError
&
e
)
{
...
...
@@ -87,7 +85,7 @@ int Gdpd::init(int nbInputs, int nbOutputs, int sampleRate) {
}
Godot
::
print
(
"GDPD :
Initialized"
);
print
(
"
Initialized"
);
return
0
;
}
...
...
@@ -100,7 +98,7 @@ void Gdpd::openfile(godot::String baseStr, godot::String dirStr) {
libpd_openfile
(
baseS
.
c_str
(),
dirS
.
c_str
());
Godot
::
print
(
"GDPD :
Opened patch"
);
print
(
"
Opened patch"
);
}
void
Gdpd
::
closefile
()
{
...
...
@@ -150,7 +148,7 @@ int Gdpd::finish_list(String destStr) {
void
Gdpd
::
print
(
const
std
::
string
&
message
)
{
Godot
::
print
(
message
.
c_str
());
Godot
::
print
(
(
std
::
string
(
"GDPD : "
)
+
message
)
.
c_str
());
}
void
Gdpd
::
receiveList
(
const
std
::
string
&
dest
,
const
pd
::
List
&
list
)
{
...
...
@@ -168,3 +166,8 @@ void Gdpd::receiveList(const std::string& dest, const pd::List& list) {
m_messages
->
push_back
(
gdlist
);
}
void
Gdpd
::
set_volume
(
float
vol
)
{
m_vol
=
vol
;
}
This diff is collapsed.
Click to expand it.
src/gdpd.hpp
+
8
−
1
View file @
79dfff51
...
...
@@ -25,6 +25,7 @@ private:
pd
::
Patch
m_patch
;
RtAudio
m_audio
;
unsigned
int
m_bufferFrames
;
float
m_vol
;
public:
static
void
_register_methods
();
...
...
@@ -47,9 +48,15 @@ public:
int
finish_list
(
String
destStr
);
//libpd hooks
void
print
(
const
std
::
string
&
message
);
virtual
void
print
(
const
std
::
string
&
message
);
void
receiveList
(
const
std
::
string
&
dest
,
const
pd
::
List
&
list
);
//godot functions
void
set_volume
(
float
vol
);
inline
const
float
&
get_volume
(){
return
m_vol
;}
//rtaudio
static
int
audioCallback
(
void
*
outputBuffer
,
void
*
inputBuffer
,
unsigned
int
nBufferFrames
,
double
streamTime
,
RtAudioStreamStatus
status
,
void
*
userData
);
};
...
...
This diff is collapsed.
Click to expand it.
src/rtaudio/RtAudio.os
+
0
−
0
View file @
79dfff51
No preview for this file type
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