Random CSV classification list

4 Ansichten (letzte 30 Tage)
Ian Mason
Ian Mason am 29 Mär. 2019
Kommentiert: Image Analyst am 1 Apr. 2019
I am designing a music shuffler in MATLAB and I need some help. I have MATLAB randomly shuffling songs and throwing in DJ's from Fallout every once in a while. I would like to have matlab create a CSV list and classify songs with a number between 1 and 10, based on how recently the song has played. Then using the randi command I would like to to choose songs with higher numbers, that haven't played recently giving them priority and making them more likely to be chosen. Every time a song plays we would make it lose one point, and so on and so fourth. And I would like to make it so that after a while it can gain points back based on a couple hours or whatever I decide on. I'm not sure how many songs I will have in the final program. The goal is for about 1000, but I only have about 20 in testing.
I have taken an entry level class to MATLAB and never understood anything about CSVs or how to have MATLAB modify them so I'm going to need a great deal of help! I'm also not great at understanding how to properly name functions, and as this will need to be a function I'll probbaly need help with that. If you have any improvements or ideas you want to make, feel free to do so. This is just for fun so I'm always open to stuff like that.
Thanks!
Here is the code that I have so far so you guys have something to go off of...
%HOLD control c to stop because it won't stop on it's own
mus = dir('mus/*.m4a');
dj = dir('dj/*.m4a');
while true
rd = randi(length(dj),1,1);
[a, Fs] = audioread(strcat(dj(rd).folder,"/",dj(rd).name));
plot(a(:,1))
title(dj(rd).name(1:end-4));
p = audioplayer(a,Fs);
play(p)
pause(length(a)/Fs);
for ii=1:randi(4)+3
rR = randi(length(mus),1,1);
[a2, Fs2] = audioread(strcat(mus(rR).folder,"/",mus(rR).name));
plot(a2(:,1))
title(mus(rR).name(1:end-4));
p = audioplayer(a2,Fs2);
play(p)
pause(length(a2)/Fs2);
end
end

Antworten (1)

Image Analyst
Image Analyst am 29 Mär. 2019
I don't know what CSV files have to do with anything unless you want to read and write some data to a csv text file.
You might look into csvread(), csvwrite(), and randperm() and randi().
  10 Kommentare
Walter Roberson
Walter Roberson am 1 Apr. 2019
What would the classification be based on? Would you be performing some kind of feature analysis on the songs to figure out what the high-rated songs had but the lower-rated songs did not, and that analysis should be used to predict whether additional songs would be high rated or not? For example, the analysis might notice that you consistently rated songs with cowbell higher, and so additional songs should have priority if they have more cowbell.
Image Analyst
Image Analyst am 1 Apr. 2019
Why not just make two lists: one for locally stored music files, and one for those in the cloud? Then you could randomly intersperse your 10 local files so that they always fall within, say, the first 30 files in the list.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by