%%
%%%% DON"T USE is ROB's MAGIC STUFF
restoredefaultpath; matlabrc 
clear all
clc
%%close all
warning off all

disp('Startup promet stuff');

addpath( ...
    genpath(fullfile('/Volumes/','VOLUME2_MAC_INT_DH/D_DRIVE/CURRENT_WORK/PROMET_2009_MATLAB')));

	

cd '/Volumes/VOLUME2_MAC_INT_DH/D_DRIVE/CURRENT_WORK/PROMET_2009_MATLAB'


%%
clear all
clc


%%%%% NETWORK PARAMETERS %%%%%


	 
% 	 %coclea
% 	 Gain_freq = 1.0;
% 	 Exp_freq  = 40.0;
% 	 Sig_freq  = 4;
% 	 nstimuli=10;
% 	 Freq_min=100;
% 	 Freq_max=10000;
% 	 
% 	 %eye pos motor neuronen
% 	 Nmsc=100;
% 	 Gain_ocul = 1/400;
% 	 Gain_pos = 7/10;
% 	 
% 	 %teacher
% 	 Gain_motor_error     = 0.7;
% 	 mot_sigma            = 10;
% 	 Motor_error_range    = 100;
	 
     %INPUT / OUTPUT Ranges
	 Azi_range = 60;        % sound position                         [-60 60]
	 Int_range = [1.0 2];   % sound intensity range                  [1.0 2.0]
	 Eye_range = 40;        % eye position                           [-40 40]
	 Mot_range = 100;       % motor error                            [-100 100]
	 Num_freq  = 5;         % number of frequency components         5
	 
%%%%% GENERAL INPUT: azi / Is  / Hor / Motor_error = azi-hor
%%%%% GENERAL INPUT: azi / Is  / Hor / Motor_error = azi-hor
%%%%% GENERAL INPUT: azi / Is  / Hor / Motor_error = azi-hor

     % VECTOR sizes
     Nfreq	 = 100; %coclea
	 Naud	 = 4;  % first hidden binaural
	 Nhidden = 10; %second hidden audiomotor
	 Nmsc	 = 100; % eye pos
	 Nmot	 = 100; % motor error teacher

%[eyepos]=eye_pos__input_V4(Nmsc,hor)

hor = randi([-Eye_range , Eye_range], 1 ,1);
[eyepos]  = eye_pos_input_V4(Nmsc, hor);

%[cochlea]=coch_input_V4(Nfreq, azi, nstimuli, Is, Freq_flag)
azi = randi( [-Azi_range , Azi_range], 1, 1)
[cochlea] = coch_input_V4(Nfreq, azi, randi(Num_freq,1,1),randi([Int_range(1), Int_range(2)],1,1), 0);

Motor_error= azi - hor;
%[motmap]=mot_input_V4(Nmot,Motor_error,Azi_range,Eye_range)
[motmap]=mot_input_V4(Nmot,Motor_error,Azi_range,Eye_range);


figure(1)
subplot(221)
     hold off
     plot((cochlea(1,:)),'k');
	 hold on
	 plot((cochlea(2,:)),'r');

	 
subplot(223)
     hold off
     plot((eyepos(1,:)),'k');
	 hold on
	 plot((eyepos(2,:)),'r');
	 axis([1 Nmsc 0 .8])
	 
	 
%%
% DIMENSION_FREQMAP: 30.0;
% DIMENSION_AUDMAP: 4.0;
% DIMENSION_EYEPOS: 10.0;
% DIMENSION_HIDDEN: 10.0;
% DIMENSION_OUTPUT: 20.0;
% 
% SIGMA_FREQMAP: 0.5;
% SIGMA_MOTMAP: 10.0;
% 
% GAIN_FREQMAP: 1;
% EXP_FREQMAP: 40;
% 
% GAIN_EYEPOS: 1;
% GAIN_MOTOR: .7;
% 
% BIAS_HID: 5;
% 
% LEARNING_RATE: 0.5;
% 
% AZIMUTH: 0.0;
% EYEPOSITION: 0.0;
% FREQUENCY: 4950.0;
% INTENSITY: 0.0;
% 
% RANDOM_FLAG: 1;
% CONTINUE_FLAG: 0;
% 
% MOTORERROR_FLAG: 0;
% AZIMUTH_FLAG: 0;
% EYE_FLAG: 0;
% FREQUENCY_FLAG: 0;
% INTENSITY_FLAG: 0;
% 
% DEMO_FLAG: 1000;
% DEMO_WAIT: 100;
% STORE_FLAG: 1;
% STORE: 0;
% 
% WEIGHTS_RANGE: .5;
% 
% AZIMUTH_RANGE: 60.0;
% EYEPOS_RANGE: 40.0;
% MOTORERROR_RANGE: 100.0:
% LOW_FREQUENCY_RANGE: 100.0;
% HIGH_FREQUENCY_RANGE: 10000.0;
% INTENSITY_RANGE: 0.40;
% 
% #V
% 1/1.wht;
% 2/2.wht;
% 3/3.wht;
% 4/4.wht;
% 5/4.wht;
% #E
