# Emit sounds over one another?

Posted 1 year ago
1541 Views
|
6 Replies
|
2 Total Likes
|
 I'm trying and failing to use "EmitSound" to play notes OVER one another. It seems that if one sound is emitted after another sound, the second sound stops the first before playing. I know that I can take a list of notes (which have lengths associated with them) and create a sound object and then play that, but the thing is, I'm trying to generate notes continuously so I need it to play on the fly, I can't "compile" the notes beforehand.See, if I play EmitSound[Sound[SoundNote[1, 10, "Trumpet"]]]; Pause[1]; EmitSound[Sound[SoundNote[1, 1, "Piano"]]] the piano cuts off the trumpet before it plays for the full 10 seconds. If I try to do something LIKE this: While[True, EmitSound[Sound[SoundNote[RandomInteger[8], {0, RandomInteger[7]}, "Trumpet"]]]; Pause[1]] It doesn't work. What I had in mind for that code was to every second play a randomly selected note between 1-8 for between 1-7 seconds, but what happens is that it just plays each note for one second as they all cut each other off. The code I'm writing in the end isn't exactly that (just random gibberish notes) but the next step is that I need to get something like this to work, thanks.
6 Replies
Sort By:
Posted 1 year ago
 EmitSound[] is an older function. If you have Version 11 or later, there is a lot of new stuff in Audio. See the documentation and some of the fine tutorials and videos on the website.Also, you should check the syntax for Emit sound. To play sounds sequentially, you put them in a list, surrounded by {}. The documentation can give you help with rests.Look at Sound[]. It may give you some clues.To accomplish your ultimate goal, you will need to use a lot of the functionality in the new Audio Processing.
Posted 1 year ago
 I guess I should have elaborated on the fact that I'm trying to generate notes continuously. I know how to play songs over one another as long as the notes are specified IN ADVANCE. But my whole problem is that I'm trying to generate an endless stream of notes here. I may be playing for one minute, I may be playing for days, I don't know ahead of time, so I can't, as you say, "put them in a list" because I don't even know how long the list will be.Believe me I've looked up and down the Sound function, and unless I'm missing something here, I do not see a way to play notes over one another unless, as you say, I put them in a list ahead of time.I am currently using Mathematica 11.0.0.0
Posted 1 year ago
 At the recent WTC, there was a talk that touched on this. This functionality is apparently coming 'soon', for a suitable definition of 'soon'. You might want to check the video from last year's WTC and this years when they are available.
Posted 1 year ago
 Is this what you need, meaning specifying not duration but the start and end of time interval of a note? Sound[{SoundNote["C", {0, 2}, "Trumpet"], SoundNote["G", {1, 3}, "Piano"]}] That was an example from the docs: SoundNote >> Scope >> Timinghttp://reference.wolfram.com/language/ref/SoundNote.htmlExperimenting with random specs, here are a few ideas: inst={"Trumpet","Piano","Organ","Violin","Voice"}; Sound[ Table[ SoundNote[3RandomInteger[{-5,5}], Sort[RandomInteger[{0,9},2]], RandomChoice[inst]], 15] ~Join~ Table[ SoundNote[3RandomInteger[{-5,5}], {#,#+.5}&@RandomReal[{0,9}], RandomChoice[inst]], 15] ]