%% Params
% Update AWD filename here
awd_filename = 'WaveOneShotPlayer_Flash';
awd_path = '';

%% Background sounds
% Reading in Excel File
[xlsnum, xlstxt, xlsraw] = xlsread('Wavefile_Index_Mapping_Loop.xlsx');

% Creating Wavemappingtable values for AudioWeaver Layout
rows = size(xlsnum,1);
name_table_background = zeros(7,rows);

for i=2:rows+1
    indx = xlsraw{i,1:1};
    if isnan(xlsraw{i,1:1})
        name = '';
    else
        name = convertStringsToChars(xlsraw{i,2:2});
    end
    name_table_background(1:7,indx+1) = string_cast_uint32(name,7);
end


%% Write AWD
% Open AudioWeaver Layout
gsys = load_awd([awd_path, awd_filename, '.awd']);

% Set Wavemappingtable values in Layout
gsys.SYS.TableSource.coeff = name_table_background;

% Get the current date and time
current_datetime = datetime('now', 'Format', 'yyMMMdd_Hmm');

% Convert the datetime to a string
datetime_string = char(current_datetime);

% Construct the new file name with date and time
new_filename = [awd_filename, '_', datetime_string, ''];

% Save new AWD file with applied Values
save_awd([awd_path, new_filename, '_mapped.awd'],gsys);

fprintf(1, 'Done\n');
    
disp('Finished')

return