Welcome,
Guest
. Please
login
or
register
. Did you miss your
activation email?
French forum
Home
Help
Search
Login
Register
SFML community forums
»
Bindings - other languages
»
DotNet
»
How to combine multiple sound buffer in real-time with C#?
Print
Pages: [
1
]
Author
Topic: How to combine multiple sound buffer in real-time with C#? (Read 6983 times)
0 Members and 1 Guest are viewing this topic.
trajan
Newbie
Posts: 2
How to combine multiple sound buffer in real-time with C#?
«
on:
October 01, 2012, 11:11:23 pm »
Sample project:
User write to music note in textbox and push "Play"...
Process begin:
Parse music note (it does not matter)
e.g.
re re mi mi do re mi (textbox)
SFML
.
Audio
.
SoundBuffer
SndBf_re
=
new
SoundBuffer
(
soundLocation
+
"re.wav"
)
;
SFML
.
Audio
.
SoundBuffer
SndBf_mi
=
new
SoundBuffer
(
soundLocation
+
"mi.wav"
)
;
SFML
.
Audio
.
SoundBuffer
SndBf_do
=
new
SoundBuffer
(
soundLocation
+
"do.wav"
)
;
How to:
SFML
.
Audio
.
Sound
UserNote
=
new
Sound
(
SndBf_re
+
SndBf_re
+
SndBf_mi
+
SndBf_mi
+
SndBf_do
+
SndBf_re
+
SndBf_mi
)
;
UserNote
.
Play
(
)
;
Process ended
sorry my bad English.
Logged
eXpl0it3r
SFML Team
Hero Member
Posts: 11030
Re: How to combine multiple sound buffer in real-time with C#?
«
Reply #1 on:
October 01, 2012, 11:27:42 pm »
I'm not sure if anyone gets what the heck you want to do/where the problem is...
There are tutorials and examples on how to use SFML if it's just about the basics.
Logged
Official FAQ:
https://www.sfml-dev.org/faq.php
Official Discord Server:
https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog:
https://duerrenberger.dev/blog/
Laurent
Administrator
Hero Member
Posts: 32498
Re: How to combine multiple sound buffer in real-time with C#?
«
Reply #2 on:
October 01, 2012, 11:48:35 pm »
Concatenate the sample arrays of eacy sound buffer into a new bigger sound buffer. But that's only if you want to save the combined music. If you just want to
play
it, then simply play one sound buffer after the other.
Logged
Laurent Gomila - SFML developer
trajan
Newbie
Posts: 2
Re: How to combine multiple sound buffer in real-time with C#?
«
Reply #3 on:
October 02, 2012, 02:59:27 pm »
Thank you everyone, following code nicely working
-need little corrections-
.
string
soundLocation
=
AppDomain
.
CurrentDomain
.
BaseDirectory
+
"notes
\\
"
;
int
totalAddedLen
=
0
;
Int16
[
]
newBigMusic
=
new
Int16
[
10000000
]
;
public
Form1
(
)
{
InitializeComponent
(
)
;
LoadAndPlay
(
)
;
}
private
void
tryProductBuffer
(
Int16
[
]
Buff
)
{
Array
.
Copy
(
Buff,
0
, newBigMusic, totalAddedLen, Buff
.
Length
)
;
totalAddedLen
=
totalAddedLen
+
Buff
.
Length
;
}
public
void
LoadAndPlay
(
)
{
SoundBuffer do_a
=
new
SoundBuffer
(
soundLocation
+
"do_a.wav"
)
;
SoundBuffer re
=
new
SoundBuffer
(
soundLocation
+
"re.wav"
)
;
SoundBuffer mi
=
new
SoundBuffer
(
soundLocation
+
"mi.wav"
)
;
SoundBuffer fa
=
new
SoundBuffer
(
soundLocation
+
"fa.wav"
)
;
SoundBuffer sol
=
new
SoundBuffer
(
soundLocation
+
"sol.wav"
)
;
SoundBuffer la
=
new
SoundBuffer
(
soundLocation
+
"la.wav"
)
;
SoundBuffer si
=
new
SoundBuffer
(
soundLocation
+
"si.wav"
)
;
SoundBuffer do_b
=
new
SoundBuffer
(
soundLocation
+
"do_b.wav"
)
;
/*
User enter textbox -> do do re re do re mi
string[0]->
if(do_a)
{
tryProductBuffer(do_a.Samples);
}
if(re)
{
tryProductBuffer(re.Samples);
}
...
*/
Array
.
Resize
(
ref
newBigMusic, totalAddedLen
)
;
SoundBuffer AllBuf
=
new
SoundBuffer
(
newBigMusic,
2
,
44100
)
;
AllBuf
.
SaveToFile
(
"newBigMusic.wav"
)
;
Sound Q
=
new
Sound
(
AllBuf
)
;
// Q.Pitch = 3;
Q
.
Play
(
)
;
}
«
Last Edit: October 02, 2012, 03:17:20 pm by trajan
»
Logged
Print
Pages: [
1
]
SFML community forums
»
Bindings - other languages
»
DotNet
»
How to combine multiple sound buffer in real-time with C#?