├── .gitignore ├── Create ├── FrostnovaMap.m ├── FrostnovaMap.m~ ├── WriteOsuFile.m └── WriteOsuFile.m~ ├── README.md ├── Read ├── checkSpectro.m ├── getOsuDataInput.m ├── getOsuDataTarget.m ├── getRhythmPoints.m ├── getRhythmPoints.m~ ├── osuFileRead.m ├── osuObjectParser.m ├── regularizeDataInputTarget.m └── test.m ├── Train ├── example.m ├── example.m~ └── osunet2.m └── save ├── checkpoint ├── model.ckpt.data-00000-of-00001 ├── model.ckpt.index └── model.ckpt.meta /.gitignore: -------------------------------------------------------------------------------- 1 | *.mat 2 | Read/osuFileRead.m 3 | -------------------------------------------------------------------------------- /Create/FrostnovaMap.m: -------------------------------------------------------------------------------- 1 | function osuObjCr=FrostnovaMap(s,y,dir,threshold) 2 | 3 | % This is the function to create a beatmap (mapping) by the trained network 4 | % and input data 5 | % ----------------Input---------------- 6 | % s: osu structure 7 | % y: result from tensorflow 8 | % dir: directory of the song 9 | % threshold: threshold for placing a object (higher threshold, more objects) 10 | % ----------------Output--------------- 11 | % 12 | % osuObj created by the inputs 13 | 14 | Ts=getRhythmPoints(s); 15 | 16 | counter=1; 17 | [~,type]=max(y,[],2); 18 | N=length(Ts); 19 | 20 | for n=1:N 21 | 22 | [tf,n_itv]=judgeslider(type,n); 23 | 24 | if type(n)==1 %circle 25 | osuObjCr(counter).timing= Ts(n); 26 | osuObjCr(counter).type = 'circle'; 27 | osuObjCr(counter).x = round(250+200*cos(Ts(n)/500)); 28 | osuObjCr(counter).y = round(200+150*sin(Ts(n)/500)); 29 | counter=counter+1; 30 | 31 | elseif tf %slider 32 | osuObjCr(counter).timing= Ts(n); 33 | osuObjCr(counter).type = 'slider'; 34 | osuObjCr(counter).x = round(250+200*cos(Ts(n)/500)); 35 | osuObjCr(counter).y = round(200+150*sin(Ts(n)/500)); 36 | osuObjCr(counter).interval = Ts(n+n_itv)-Ts(n); 37 | osuObjCr(counter).length = n_itv; 38 | type(n+n_itv)=3; %assign a slider end 39 | osuObjCr(counter).turns = 1; 40 | counter=counter+1; 41 | 42 | elseif type(n)==4||3 %empty or slider end 43 | 44 | 45 | else %circle 46 | osuObjCr(counter).timing= Ts(n); 47 | osuObjCr(counter).type = 'circle'; 48 | osuObjCr(counter).x = round(250+200*cos(Ts(n)/500)); 49 | osuObjCr(counter).y = round(200+150*sin(Ts(n)/500)); 50 | counter=counter+1; 51 | end 52 | 53 | end 54 | 55 | diffname='FrOstNovA2'; 56 | WriteOsuFile(s,osuObjCr,dir,diffname) 57 | 58 | end 59 | 60 | 61 | function [tf,n_itv]=judgeslider(type,n) 62 | 63 | N=length(type); 64 | n_itv=0; 65 | tf=0; 66 | 67 | if n>N||type(n)~=2 68 | tf=0; 69 | else 70 | k=n+1; 71 | while k','markersize',10) 37 | plot([j,j],[0,1],'b') 38 | elseif tp==3 %sliderEnd 39 | plot([j,j],[0,1],'b') 40 | plot([j-0.5,j],[0.5,0.5],'b->','markersize',10) 41 | end 42 | end 43 | 44 | xlim([1,9]) 45 | ylim([0,1]) 46 | end 47 | 48 | end -------------------------------------------------------------------------------- /Read/getOsuDataInput.m: -------------------------------------------------------------------------------- 1 | function [input,TS,TQ,FQ] = getOsuDataInput(s,songfile) 2 | 3 | % This function is for generating the inputs to the neural network, as a 4 | % formatized data of the songfile. 5 | % 6 | % Specially designed for convolution NN "FrostNova" Ver1 7 | % -----------Input------------ 8 | % Ts: the rhythm poitns of the song, Ts=Ts=getRhythmPoints(s), where s 9 | % is the osu structure. 10 | % songfile: the path of the music file. 11 | % -----------Output------------ 12 | % osuDataInput: A Tensor of input for TENSORFLOW, each data set contains 13 | % the matrix of spectrogram around a rhythm point. 14 | % 15 | % ----------------------- 16 | % By Dongqi Han, OIST 17 | 18 | t_reso = 15; % temporal resolution estimation(in milisecond) 19 | N_t = 128; % divide 20 | P = 4; 21 | fq=linspace(0,10000,128); %range of frequency 22 | 23 | %----------- read data ------------- 24 | [data0,fs]=audioread(songfile); 25 | data1=data0(:,1); %left channel 26 | data2=data0(:,2); %right channel 27 | 28 | Nfft=round(fs/(1000/(t_reso))); 29 | window=hann(2*Nfft+1); 30 | 31 | [S1,~,~]=spectrogram(data1,window,[],Nfft,fs); 32 | 33 | S1 = log(1+abs(S1)); 34 | S1 = S1 / max(max(S1)); %normalize 35 | 36 | [S2,f,t]=spectrogram(data2,window,[],Nfft,fs); 37 | t=t*1000; %convert to ms 38 | t=t-t_reso;%modify 39 | 40 | S2 = log(1+abs(S2)); 41 | S2 = S2 / max(max(S2)); %normalize 42 | 43 | S=(S1+S2)/2; 44 | 45 | 46 | 47 | Ts=getRhythmPoints(s); 48 | 49 | 50 | osuDataInput=zeros(length(Ts),length(fq),N_t,'gpuArray'); %Input Tensor 51 | 52 | 53 | 54 | % for n=1:length(Ts) %drop the first and last timing points. 55 | % 56 | % tq(1:N_t+1)=linspace(Ts(n-1),Ts(n),N_t+1); 57 | % tq(N_t+1:2*N_t+1)=linspace(Ts(n),Ts(n+1),N_t+1); 58 | % 59 | % tmp=interp1(T,S_t,tq); 60 | % 61 | % osuDataInput(n,n-1)=tmp/max(tmp); 62 | % 63 | % end 64 | 65 | 66 | [TS,~]=meshgrid(Ts,f); 67 | [T,F]=meshgrid(t,f); 68 | 69 | Sg=gpuArray(S); 70 | Tg=gpuArray(T); 71 | Fg=gpuArray(F); 72 | 73 | for n=1:length(Ts) 74 | tq=linspace(Ts(max(n-P,1)),Ts(min(n+P,length(Ts))),N_t); 75 | 76 | [TQ,FQ]=meshgrid(tq,fq); 77 | TQg=gpuArray(TQ); 78 | FQg=gpuArray(FQ); 79 | 80 | osuDataInput(n,:,:)=interp2(Tg,Fg,Sg,TQg,FQg); 81 | osuDataInput(n,:,:)=osuDataInput(n,:,:)/max(max(osuDataInput(n,:,:))); 82 | if mod(n,100)==1 83 | n 84 | end 85 | end 86 | 87 | input=gather(osuDataInput); 88 | 89 | end -------------------------------------------------------------------------------- /Read/getOsuDataTarget.m: -------------------------------------------------------------------------------- 1 | function [osuDataTarget,osuDataTiming] = getOsuDataTarget(s) 2 | 3 | % This function is for generating the targets to the neural network, as a 4 | % formatized data of the the beatmap created by humans. 5 | % 6 | % Specially designed for convolution NN "FrostNova" Ver1 7 | % -----------Input------------ 8 | % Ts: the rhythm poitns of the song, Ts=Ts=getRhythmPoints(s), where s 9 | % is the osu structure. 10 | % osuObj: the objects of the map, osuObj=osuObjectParser(s); 11 | % -----------Output------------ 12 | % osuDataTarget: A Tensor of target for TENSORFLOW, each data set has 4 13 | % dimensions: {isCircle, isSliderHead, is SliderEnd, empty} 14 | % 15 | % ----------------------- 16 | % By Dongqi Han, OIST 17 | 18 | Ts=getRhythmPoints(s); 19 | osuObj=osuObjectParser(s); 20 | 21 | osuDataTarget=zeros(length(Ts),4); 22 | osuDataTiming=zeros(length(Ts),1); 23 | 24 | z0=1; 25 | while osuObj(z0).timing3&&(Ts(n)-osuObj(z).timing<10) 35 | n=n+1; 36 | end 37 | 38 | if n>=length(Ts) 39 | break; 40 | end 41 | 42 | if n>1 && abs(osuObj(z).timing-Ts(n))<3 43 | switch osuObj(z).type 44 | case 'circle' 45 | osuDataTarget(n,1)=1; % circle 46 | case 'slider' 47 | 48 | if osuObj(z).turns>1 49 | for k=0:osuObj(z).turns 50 | osuDataTarget(n+k*(osuObj(z).length),1)=1; %regard returning sliders as circles 51 | end 52 | else 53 | osuDataTarget(n,2)=1; % silderHead 54 | osuDataTarget(n+osuObj(z).length,3)=1; %sliderEnd 55 | end 56 | case 'spinner' 57 | osuDataTarget(n,2)=1; %regard spinnerHead as SliderHead 58 | otherwise 59 | 60 | end 61 | osuDataTiming(n)=osuObj(z).timing; 62 | end 63 | 64 | 65 | 66 | n=n+1; 67 | 68 | 69 | end 70 | 71 | for i = 1:length(Ts) 72 | if sum(osuDataTarget(i,1:3),2)==0 73 | osuDataTarget(i,4)=1; 74 | end 75 | end 76 | 77 | end 78 | 79 | -------------------------------------------------------------------------------- /Read/getRhythmPoints.m: -------------------------------------------------------------------------------- 1 | function [Ts,InheritedTimings]=getRhythmPoints(s) 2 | 3 | % This is the function for generating the rhythm points where the hitObjects can be placed 4 | % (white and red shot lines in the upper time line in osu! editor.) 5 | % 6 | % output: Ts-- a list of rhythm points. 7 | % input: s-- beatmap structure, where s=osuFileRead(osufile); 8 | % temporal unit all in milisecond 9 | % By Dongqi Han, OIST 10 | 11 | osuObj=osuObjectParser(s); 12 | 13 | Ts=zeros(1e6,1); 14 | InheritedTimings=zeros(1e6,1); 15 | 16 | q=1; %index 17 | j=1; %index 18 | z=1; %index 19 | startTiming=textscan(s.TimingPoints{1},'%f,%f,%f'); 20 | beatDivisor=str2double(s.Editor.BeatDivisor); 21 | 22 | Ts(1)=startTiming{1}; 23 | InheritedTimings(1)=100; 24 | InheritedTiming=100; 25 | 26 | 27 | t=Ts(1); 28 | tmptp=textscan(s.TimingPoints{j},'%f,%f,%f'); 29 | lengthof1pai_next=tmptp{2}; 30 | lengthof1pai=lengthof1pai_next; 31 | isend=0; 32 | 33 | 34 | tmptp1=textscan(s.TimingPoints{q},'%f,%f,%f'); 35 | 36 | 37 | while 1 38 | 39 | while q<=length(s.TimingPoints) 40 | 41 | tmptp1=textscan(s.TimingPoints{q},'%f,%f,%f'); 42 | 43 | if q<=length(s.TimingPoints)&&tmptp1{1}=0 45 | BPMnow=60000/tmptp1{2}; 46 | else 47 | InheritedTiming=abs(tmptp1{2}); 48 | beats=tmptp1{3}; 49 | end 50 | q=q+1; 51 | else 52 | break 53 | end 54 | 55 | 56 | end 57 | 58 | 59 | if Ts(z)>=tmptp{1} && ~isend 60 | lengthof1pai=lengthof1pai_next; 61 | t=tmptp{1}+(lengthof1pai/beatDivisor); 62 | if j<=length(s.TimingPoints) 63 | while 1 64 | j=j+1; 65 | if j>length(s.TimingPoints) 66 | isend=1; 67 | break; 68 | end 69 | tmptp=textscan(s.TimingPoints{j},'%f,%f,%f'); 70 | if tmptp{2}>0 71 | lengthof1pai_next=tmptp{2}; 72 | break; 73 | end 74 | 75 | end 76 | end 77 | end 78 | 79 | 80 | 81 | 82 | t=t+(lengthof1pai/beatDivisor); 83 | 84 | 85 | Ts(z+1)=round(t); 86 | InheritedTimings(z+1)=InheritedTiming; 87 | 88 | z=z+1; 89 | 90 | 91 | if t >= osuObj(end).timing 92 | break; 93 | end 94 | 95 | end 96 | 97 | idxdel=find(Ts<=0); 98 | Ts(idxdel)=[]; 99 | InheritedTimings(idxdel)=[]; 100 | 101 | end -------------------------------------------------------------------------------- /Read/getRhythmPoints.m~: -------------------------------------------------------------------------------- 1 | function [Ts,InheritedTimings]=getRhythmPoints(s) 2 | 3 | % This is the function for generating the rhythm points where the hitObjects can be placed 4 | % (white and red shot lines in the upper time line in osu! editor.) 5 | % 6 | % output: Ts-- a list of rhythm points. 7 | % input: s-- beatmap structure, where s=osuFileRead(osufile); 8 | % temporal unit all in milisecond 9 | % By Dongqi Han, OIST 10 | 11 | osuObj=osuObjectParser(s); 12 | 13 | Ts=zeros(1e6,1); 14 | InheritedTimings=zeros(1e6,1); 15 | 16 | q=1; %index 17 | j=1; %index 18 | z=1; %index 19 | startTiming=textscan(s.TimingPoints{1},'%f,%f,%f'); 20 | beatDivisor=str2double(s.Editor.BeatDivisor); 21 | 22 | Ts(1)=startTiming{1}; 23 | InheritedTimings(1)=100; 24 | InheritedTiming=100; 25 | 26 | 27 | t=Ts(1); 28 | tmptp=textscan(s.TimingPoints{j},'%f,%f,%f'); 29 | lengthof1pai_next=tmptp{2}; 30 | isend=0; 31 | 32 | 33 | tmptp1=textscan(s.TimingPoints{j},'%f,%f,%f'); 34 | 35 | 36 | while 1 37 | 38 | while q<=length(s.TimingPoints) 39 | 40 | tmptp=textscan(s.TimingPoints{q},'%f,%f,%f'); 41 | 42 | if q<=length(s.TimingPoints)&&tmptp{1}=0 44 | BPMnow=60000/tmptp{2}; 45 | else 46 | InheritedTiming=abs(tmptp{2}); 47 | beats=tmptp{3}; 48 | end 49 | q=q+1; 50 | else 51 | break 52 | end 53 | 54 | 55 | end 56 | 57 | 58 | if Ts(z)>=tmptp{1} && ~isend 59 | lengthof1pai=lengthof1pai_next; 60 | t=tmptp{1}+(lengthof1pai/beatDivisor); 61 | if jlength(s.TimingPoints) 65 | isend=1; 66 | break; 67 | end 68 | tmptp=textscan(s.TimingPoints{j},'%f,%f,%f'); 69 | if tmptp{2}>0 70 | lengthof1pai_next=tmptp{2}; 71 | break; 72 | end 73 | 74 | end 75 | end 76 | end 77 | 78 | 79 | t=t+(lengthof1pai/beatDivisor); 80 | 81 | 82 | Ts(z+1)=round(t); 83 | InheritedTimings(z+1)=InheritedTiming; 84 | 85 | z=z+1; 86 | 87 | 88 | if t >= osuObj(end).timing 89 | break; 90 | end 91 | 92 | end 93 | 94 | idxdel=find(Ts<=0); 95 | Ts(idxdel)=[]; 96 | InheritedTimings(idxdel)=[]; 97 | 98 | end -------------------------------------------------------------------------------- /Read/osuFileRead.m: -------------------------------------------------------------------------------- 1 | function s=osuFileRead(osufilename) 2 | 3 | 4 | fg=fopen(osufilename,'r'); 5 | version=fgetl(fg); 6 | version=regexp(version,'\d+','match'); 7 | version=version{1}; 8 | version=str2double(version); 9 | str=fscanf(fg,'%c'); 10 | str=regexprep(str,'[ ]*:[ ]*',':'); 11 | str=regexprep(str,'"',''); 12 | str=regexprep(str,'//[\S ]*\r\n',''); 13 | str=regexprep(str,'(?<=[a-zA-Z]):(?=[\S\r])','":"'); 14 | str=regexprep(str,'(?<=Combo\d):(?=[\S\r])','":"'); 15 | str=regexprep(str,'\r\n','",\r\n"'); 16 | str=regexprep(str,'(?=0 39 | BPMnow=60000/tmptp{2}; 40 | else 41 | InheritedTiming=abs(tmptp{2}); 42 | beats=tmptp{3}; 43 | end 44 | j=j+1; 45 | else 46 | break 47 | end 48 | 49 | 50 | end 51 | 52 | 53 | osuObj(i).currentBPM=BPMnow; 54 | osuObj(i).inheritedTiming=InheritedTiming; 55 | 56 | [C,~] = textscan(s.HitObjects{i},'%f,%f,%f,%f,%f,%c'); 57 | 58 | %-----------------------spinner------------------------ 59 | if tmp{6}>10 %spinner 60 | osuObj(i).type='spinner'; 61 | osuObj(i).interval=tmp{6}-osuObj(i).timing; 62 | 63 | 64 | %-----------------------slider------------------------ 65 | 66 | 67 | elseif isempty(tmp{6})&&~isempty(C{6}) 68 | osuObj(i).type='slider'; 69 | [C,pos] = textscan(s.HitObjects{i},'%f,%f,%f,%f,%f,%c'); 70 | pos1=0; 71 | 72 | 73 | while ~isempty(C{1}) 74 | 75 | pos=pos+pos1; 76 | [C,pos1] = textscan(s.HitObjects{i}(pos+1:end),'|%f:%f'); 77 | end 78 | 79 | 80 | tmp2 = textscan (s.HitObjects{i}(pos+1:end),',%f,%f,%f'); 81 | osuObj(i).turns=tmp2{1}; 82 | 83 | SliderLength=tmp2{2}; 84 | 85 | %slider time length (interval) 86 | osuObj(i).interval=SliderLength*InheritedTiming/SliderMultiplier/10000*(60000/osuObj(i).currentBPM); 87 | osuObj(i).length=round( str2double(s.Editor.BeatDivisor) * osuObj(i).interval/(60000/osuObj(i).currentBPM)); % how many points 88 | 89 | %-----------------------circle------------------------ 90 | 91 | else %circle 92 | osuObj(i).type='circle'; 93 | end 94 | 95 | 96 | end 97 | 98 | 99 | 100 | 101 | 102 | end -------------------------------------------------------------------------------- /Read/regularizeDataInputTarget.m: -------------------------------------------------------------------------------- 1 | function [input1,target1]=regularizeDataInputTarget(input,target) 2 | 3 | % This function is for kicking out some of the thythm points without 4 | % objects, so that the number of inputs with a target 0,1 will have 5 | % similar numbers 6 | 7 | 8 | idx0=find(target(:,4)==1); 9 | idx1=find(target(:,4)==0); 10 | 11 | if (length(idx0)>length(idx1)) 12 | idxdelete=idx0(randperm(length(idx0),length(idx0)-length(idx1))); 13 | 14 | 15 | input(idxdelete,:,:)=[]; 16 | target(idxdelete,:)=[]; 17 | 18 | end 19 | 20 | input1=input; 21 | target1=target; 22 | 23 | end -------------------------------------------------------------------------------- /Read/test.m: -------------------------------------------------------------------------------- 1 | 2 | [songdata,fs]=audioread(songfile); 3 | 4 | ajiduration=0.01; %in second 5 | Naji=50; 6 | 7 | Nfft=fs*ajiduration*2; 8 | [S,F,T]=spectrogram(songdata(:,1),Nfft,Nfft/2,Nfft,fs); 9 | 10 | S2=log(abs(S)); 11 | 12 | data=sum(S2,1); 13 | data=mapminmax(data,0,1); 14 | 15 | idx = (-Naji/2):(Naji/2); 16 | 17 | 18 | for m=10:(length(osuObj)-20) 19 | 20 | [~,Tind]=min(abs(1000*T-osuObj(m).timing)); 21 | timepoints = Tind+idx; 22 | 23 | aji(m-9,:)=data(timepoints); 24 | 25 | 26 | end 27 | 28 | aji=aji/max(max(aji)); 29 | 30 | for m=10:(length(osuObj)-20) 31 | 32 | if strcmp('circle',osuObj(m).type) 33 | ren(m-9,1)=1; % circle 34 | else 35 | ren(m-9,1)=0; %slider or spinner 36 | end 37 | 38 | end 39 | 40 | -------------------------------------------------------------------------------- /Train/example.m: -------------------------------------------------------------------------------- 1 | 2 | 3 | % dir=... 4 | % 'E:\Program Files (x86)\osu!\Songs\39325 SHIKI - Pure Ruby\'; 5 | % osufilename=[dir,... 6 | % 'SHIKI - Pure Ruby (tsuka) [Another].osu']; 7 | % songfile=[dir,... 8 | % 'Pure Ruby.mp3']; 9 | 10 | % 11 | % dir=... 12 | % '/Users/dongqihan/Downloads/opsu/Songs/'; 13 | % osufilename=[dir,... 14 | % 'IOSYS - Power of Dream (Night Fever Refix) (Kite) [Power of Stream].osu']; 15 | % songfile=[dir,... 16 | % '11. Power of Dream Refix.mp3']; 17 | % 18 | 19 | % dir=... 20 | % '/Users/dongqihan/Documents/MATLAB/OSU/FrOstNovaV2.0/osufiles/'; 21 | % osufilename=[dir,... 22 | % 'Daisuke Achiwa - BASARA (100pa-) [BASARA].osu']; 23 | % songfile=[dir,... 24 | % 'BASARA.mp3']; 25 | 26 | % 27 | % 28 | % dir=... 29 | % '/Users/dongqihan/Downloads/opsu/Songs/155118 Drop - Granat/'; 30 | % osufilename=[dir,... 31 | % 'Drop - Granat (Lan wings) [Extra].osu']; 32 | % songfile=[dir,... 33 | % '7.VII. Granat.mp3']; 34 | % % % 35 | dir=... 36 | 'C:\Users\hdqhd\AppData\Local\osu!\Songs\13019 Daisuke Achiwa - BASARA\'; 37 | 38 | osufilename=[dir,... 39 | 'Daisuke Achiwa - BASARA (100pa-) [BASARA].osu']; 40 | songfile=[dir,... 41 | 'BASARA.mp3']; 42 | 43 | s=osuFileRead(osufilename); 44 | Ts=getRhythmPoints(s); 45 | osuObj=osuObjectParser(s); 46 | osuDataInput = getOsuDataInput(s,songfile); 47 | osuDataTarget = getOsuDataTarget(s); 48 | 49 | target=osuDataTarget; 50 | input=osuDataInput; 51 | [input1,target1]=regularizeDataInputTarget(input,target); 52 | 53 | 54 | % 55 | % clear NET 56 | % clear TR 57 | % M=3; 58 | % for i=1:M 59 | % net=osunet2([33,33,1]); 60 | % [net,tr]=train(net,input1,target1); 61 | % NET{i}=net; 62 | % TR{i}=tr; 63 | % end 64 | % 65 | % pf=zeros(M,1); 66 | % for i = 1:M 67 | % pf(i)=TR{i}.best_tperf; 68 | % end 69 | % 70 | % [~,ind]=min(pf); 71 | % net=NET{ind}; 72 | % 73 | % Y=net(input1); 74 | % figure 75 | % plot(Y(180:190),'r'); 76 | % hold on 77 | % plot(target1(180:190),'b'); 78 | % 79 | % figure 80 | % plot(round(Y(80:95)),'r'); 81 | % hold on 82 | % plot(target1(80:95),'b'); 83 | % 84 | % figure 85 | % hist(round(Y)-target1) 86 | % 87 | % osuObjCr=FrostnovaMap(s,input,net,dir,0.5); 88 | % 89 | % 90 | % 91 | -------------------------------------------------------------------------------- /Train/example.m~: -------------------------------------------------------------------------------- 1 | 2 | 3 | % dir=... 4 | % 'E:\Program Files (x86)\osu!\Songs\39325 SHIKI - Pure Ruby\'; 5 | % osufilename=[dir,... 6 | % 'SHIKI - Pure Ruby (tsuka) [Another].osu']; 7 | % songfile=[dir,... 8 | % 'Pure Ruby.mp3']; 9 | 10 | 11 | dir=... 12 | '/'; 13 | osufilename=[dir,... 14 | 'IOSYS - Power of Dream (Night Fever Refix) (Kite) [Power of Stream].osu']; 15 | songfile=[dir,... 16 | '11. Power of Dream Refix.mp3']; 17 | 18 | 19 | % dir=... 20 | % '/Users/dongqihan/Documents/MATLAB/OSU/FrOstNovaV2.0/osufiles/'; 21 | % osufilename=[dir,... 22 | % 'Daisuke Achiwa - BASARA (100pa-) [BASARA].osu']; 23 | % songfile=[dir,... 24 | % 'BASARA.mp3']; 25 | 26 | % 27 | % dir=... 28 | % 'E:\Program Files (x86)\osu!\Songs\155118 Drop - Granat\'; 29 | % osufilename=[dir,... 30 | % 'Drop - Granat (Lan wings) [Extra].osu']; 31 | % songfile=[dir,... 32 | % '7.VII. Granat.mp3']; 33 | % % 34 | % dir=... 35 | % 'E:\Program Files (x86)\osu!\Songs\13019 Daisuke Achiwa - BASARA\'; 36 | % 37 | % osufilename=[dir,... 38 | % 'Daisuke Achiwa - BASARA (100pa-) [BASARA].osu']; 39 | % songfile=[dir,... 40 | % 'BASARA.mp3']; 41 | 42 | s=osuFileRead(osufilename); 43 | Ts=getRhythmPoints(s); 44 | osuObj=osuObjectParser(s); 45 | osuDataInput = getOsuDataInput(s,songfile); 46 | osuDataTarget = getOsuDataTarget(s); 47 | 48 | target=osuDataTarget; 49 | input=osuDataInput; 50 | [input1,target1]=regularizeDataInputTarget(input,target); 51 | 52 | 53 | % 54 | % clear NET 55 | % clear TR 56 | % M=3; 57 | % for i=1:M 58 | % net=osunet2([33,33,1]); 59 | % [net,tr]=train(net,input1,target1); 60 | % NET{i}=net; 61 | % TR{i}=tr; 62 | % end 63 | % 64 | % pf=zeros(M,1); 65 | % for i = 1:M 66 | % pf(i)=TR{i}.best_tperf; 67 | % end 68 | % 69 | % [~,ind]=min(pf); 70 | % net=NET{ind}; 71 | % 72 | % Y=net(input1); 73 | % figure 74 | % plot(Y(180:190),'r'); 75 | % hold on 76 | % plot(target1(180:190),'b'); 77 | % 78 | % figure 79 | % plot(round(Y(80:95)),'r'); 80 | % hold on 81 | % plot(target1(80:95),'b'); 82 | % 83 | % figure 84 | % hist(round(Y)-target1) 85 | % 86 | % osuObjCr=FrostnovaMap(s,input,net,dir,0.5); 87 | % 88 | % 89 | % 90 | -------------------------------------------------------------------------------- /Train/osunet2.m: -------------------------------------------------------------------------------- 1 | function net=osunet2(layersizes) 2 | % An multi-layer neural network for simulation of birdsong neurons. 3 | % layersize: [layersize1,layersize2,...,layersizeN] 4 | % version2 5 | % Created by Dongqi Han,OIST 6 | 7 | net = network; 8 | 9 | %--------------------Network Properties------------------------ 10 | net.numInputs=1; 11 | % net.inputs{1}.size=[size(X{1},1),size(X{1},2)]; 12 | 13 | net.numLayers=length(layersizes); 14 | 15 | %----define connectivities--- 16 | 17 | net.inputConnect(1,:)=1; % only the first la yer has input 18 | net.outputConnect(net.numLayers)=1; % output only from the last layer 19 | 20 | for n=1:net.numLayers 21 | net.biasConnect(n)=1; %every layer has bias 22 | end 23 | 24 | for i=1:net.numLayers 25 | for j=1:net.numlayers 26 | if i==j+1 27 | net.layerConnect(i,j)=1; % one layer only connect to the next one 28 | end 29 | end 30 | end 31 | 32 | %----define layer properties------ 33 | for n=1:net.numLayers 34 | net.layers{n}.transferFcn='tansig'; 35 | net.layers{n}.size=layersizes(n); %number of neurons 36 | end 37 | 38 | net.layers{net.numLayers}.transferFcn='satlin'; %The last layer, linear 39 | % net.layers{net.numLayers}.initFcn='initnw'; 40 | 41 | %----define functions-------- 42 | net.trainFcn='trainlm'; 43 | net.trainParam.lr = 0.01; 44 | net.trainParam.min_grad=0; 45 | net.trainParam.epochs=10000; 46 | net.trainParam.max_fail=30; 47 | net.trainParam.goal=1e-5; 48 | 49 | net.divideFcn='dividerand'; 50 | net.divideParam.trainRatio=0.4; 51 | net.divideParam.valRatio=0.2; 52 | net.divideParam.testRatio=0.4; 53 | net.performFcn='mse'; 54 | 55 | net.plotFcns={'plotperform', 'plottrainstate', 'ploterrhist', 'plotroc'}; 56 | 57 | 58 | %----define input properties----- 59 | net.inputs{:}.range=[0,1]; %the probability of firing 60 | net.inputs{:}.size=0; 61 | 62 | %----define output properties----- 63 | net.outputs{net.numLayers}.range=[0,1]; %the probability of firing 64 | 65 | 66 | % %----initialize IW,LW------ 67 | % for i=1:1 68 | % for j=1:1 69 | % net.IW{i,j}=rand(size(net.IW{i},1),size(net.IW{i},2)); 70 | % end 71 | % end 72 | 73 | 74 | 75 | for i=2:net.numLayers 76 | j=i-1; 77 | 78 | net.LW{i,j}=rand(size(net.LW{i,j},1),size(net.LW{i,j},2)); 79 | 80 | end 81 | %----------------------------- 82 | 83 | 84 | end -------------------------------------------------------------------------------- /save/checkpoint: -------------------------------------------------------------------------------- 1 | model_checkpoint_path: "F:/github/OSU-automapping/save/model.ckpt" 2 | all_model_checkpoint_paths: "F:/github/OSU-automapping/save/model.ckpt" 3 | -------------------------------------------------------------------------------- /save/model.ckpt.data-00000-of-00001: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrostHan/OSU-automapping/a60e9c90d13969e693fdbb838e4cce6ea50ba1ca/save/model.ckpt.data-00000-of-00001 -------------------------------------------------------------------------------- /save/model.ckpt.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrostHan/OSU-automapping/a60e9c90d13969e693fdbb838e4cce6ea50ba1ca/save/model.ckpt.index -------------------------------------------------------------------------------- /save/model.ckpt.meta: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrostHan/OSU-automapping/a60e9c90d13969e693fdbb838e4cce6ea50ba1ca/save/model.ckpt.meta --------------------------------------------------------------------------------