I used wavread() to read in 3 wave files:
[wave_1 f1]=wavread(s1);
[wave_2 f2]=wavread(s2);
[wave_3 f3]=wavread(s3);
where s1,s2,s3 are the paths for the wave files. The problem is that they are played all at once. How can I play the first, then the second, then the third one after the another?
To play the files sequentially, use the playblocking function. Here is what your code would look like:
[wave_1 f1] = wavread(s1);
[wave_2 f2] = wavread(s2);
[wave_3 f3] = wavread(s3);
player1 = audioplayer(wave_1, f1);
playblocking(player1);
player2 = audioplayer(wave_2, f2);
playblocking(player2);
player3 = audioplayer(wave_3, f3);
playblocking(player3);
Related
My problem with the writing function is how can I write all the video frames and audio?
Because the step function writes only the last frame.
What loop condition am I using that enables me to write all frames and audio?
readObject = vision.VideoFileReader('video_001.avi', 'AudioOutputPort',true);
writeObject = vision.VideoFileWriter('video17.avi', 'FileFormat','avi', 'AudioInputPort',true, 'FrameRate',readObject.info.VideoFrameRate, 'Quality',90);
writeObject.AudioInputPort=true;
while ~isDone(readObject)
[frame, audio] = step(readObject); %[frame, audio] = avi();
end
step(writeObject,frame, audio); %mp4(frame, audio);
release(readObject);
release(writeObject);
I want to make a loop to read and another loop separate to write
How do I do that?
I appreciate any help for me...
So this is my code for a MATLAB program that works like this:
I have a folder with 10 .mp3 songs ( /songs ) and a folder with test files ( /tests ).
Test are just 10s cutouts of songs from the /songs folder
What I do is:
1) move to songs dir, and load songs into a list
cd(path_to_songs_dir)
songList = dir('*.mp3');
numSongs= numel(songList);
for i=1:numSongs
[y{i}, fs{i}] = audioread(songList(i).name);
end
2) load test file
[y_test, fs_test] = audioread(path_to_test_file);
3) create a gallery for the graphs
for t=1:numSongs
gallery{t}=y{t}(:,1);
end
4) use cross correlation to determine which song has the highest cross correlation value with my test file
for g=1:numSongs
[xc{g},lagc{g}]= xcorr(gallery{g},y_test(:,1),'none');
if g == 1
[maxcorr,maxli] = max(xc{g});
n_song = g;
elseif g ~= 1 && max(xc{g}) > maxcorr
[maxcorr,maxli] = max(xc{g});
n_song = g;
end
end
The program works just fine and is pretty good at recognizing songs, but it is excruciatingly slow. It may take up to an entire minute, and it only has to compare the test againt 10 songs.
Any idea to make it faster? Any kind of suggestion on improving the code is appreciated, this is one of my very first attempts to use MATLAB
I like h2o.ai for machine learning using R.
https://cran.r-project.org/web/packages/h2o/h2o.pdf
I like random forests, but I'm making a few thousand predictions in a loop.
It is spamming up my memory with things like this:
I can't afford to keep them all in memory. I'm making my very nice computer work very hard. That means it doesn't have the capacity to hold all the balls in the air at once.
If I could assign a destination frame name to the prediction then each new one would overwrite the old ones.
How do I assign a destination frame name when I am performing "h2o.predict" on an object?
Things that I have tried that did not work:
h2o.predict(object = rf.hex, newdata = test.hex, predictions_frame = "predict.hex")
h2o.predict(object = rf.hex, newdata = test.hex, destination_frame = "predict.hex")
h2o.predict(object = rf.hex, newdata = test.hex, model_id = "predict.hex")
There is no way that I am aware of.
But as an alternative, inside your loop, you could call h2o.rm() on the return value from h2o.predict(). It is worth calling h2o.gc() as well. Something like:
for(data in alldata){
# ... prepare newdata
p = h2o.predict(model, newdata)
# ... do something with p here
h2o.rm(p)
h2o.rm(newdata) # If also not needed any more
h2o.gc()
}
Aside: you said "I'm making a few thousand predictions in a loop". Assuming they were all against the same model, remember you can batch them up, and give all thousand predictions in a single newdata dataframe. One call to h2o.predict() with 1000 entries is much more efficient than making 1000 h2o.predict() calls, for one newdata entry at a time.
I've been going through documentation looking for an answer for this. I see that AudioKit can draw waveforms for in realtime as you record or playback, but I was wondering if you could load in a file and it draw the waveform in full so I can see the whole file's waveform without playing it back.
Any help would be greatly appreciated. Even just a pointer to what object I should look into.
You can also use the Objective C EZAudioPlot class which is in AudioKitUI:
let file = EZAudioFile(url: url)
guard let data = file?.getWaveformData() else { return }
let waveform = EZAudioPlot()
addSubview( waveform )
waveform.frame = NSMakeRect(0, 0, 200, 20)
waveform.plotType = EZPlotType.buffer
waveform.shouldFill = true
waveform.shouldMirror = true
waveform.color = NSColor.black
waveform.updateBuffer( data.buffers[0], withBufferSize: data.bufferSize )
I haven't benchmarked the two methods, but the plot version is very fast for longer files. For stereo files, make two stacked plots using buffers[0] and [1]
there is a waveform that is drawn in the tables playground example here: http://audiokit.io/playgrounds/Basics/Tables/
Basically:
let file = try AKAudioFile(readFileName: "drumloop.wav")
let fileTable = AKTable(file: file)
...UI set up...
addView(AKTableView(fileTable))
I have this queue config
[1XXX]
musiconhold = default
strategy = ringall
timeout = 30
retry = 1
weight = 0
wrapuptime = 5
maxlen = 0
periodic-announce = /var/lib/asterisk/agi-bin/xxxx/resources/audio/gsm/waiting_1
periodic-announce-frequency = 15
relative-periodic-announce = yes
announce-holdtime = no
joinempty = yes
ringinuse = false
member => SIP/1001
member => SIP/1002
member => SIP/1003
What I cant do is make the waiting_1 announcment to play in begining and for first time not wait the 15 seconds. This is my fist time with AsteriskNOW or Asterisk in particular, so please be straightforward. :)
You have 2 choices
1) create moh class in which put your announce as you wish(mix sound files),assing that class to queue
2) play announce before queue. unfortanly that will result delay in processing.
Sorrry,no other ways.
You can also use sort option in the moh class. And put files with names like 1.wav 2.wav and so on to the directory
this is config file documentation
example of musiconhold.conf:
[announceclass]
mode=files
directory=announce
sort=alpha ; Sort the files in alphabetical order.
after this just create directory announce, copy music files there, and name it like:
1.announce.wav
2.wav
3.wav
...
10.wav
...
so, the 1.announce.wav will be played first
and choose moh class in queues.conf
[q1]
musicclass = announceclass
But you should put a lot of files, if you don't want to make your caller to listen announce twice.