|
|
|
@ -138,10 +138,12 @@ drum_config_t drum_config[NUM_DRUMSET_CONFIG] = |
|
|
|
|
{ |
|
|
|
|
EOF |
|
|
|
|
|
|
|
|
|
declare -A converted_files |
|
|
|
|
|
|
|
|
|
while IFS= read -r l |
|
|
|
|
do |
|
|
|
|
declare -A sample |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [[ "${l:0:1}" == "#" ]] |
|
|
|
|
then |
|
|
|
|
continue |
|
|
|
@ -151,6 +153,7 @@ do |
|
|
|
|
sample['class']=`echo "${samplecfg[0]}" | xargs` |
|
|
|
|
sample['midinote']=`echo "${samplecfg[1]}" | xargs` |
|
|
|
|
sample['name']=`echo "${samplecfg[2]}" | xargs` |
|
|
|
|
sample['data_name']="${sample['name']}" |
|
|
|
|
sample['shortname']=`echo "${samplecfg[3]}" | xargs` |
|
|
|
|
sample['pitch']=`echo "${samplecfg[4]}" | xargs` |
|
|
|
|
sample['pan']=`echo "${samplecfg[5]}" | xargs` |
|
|
|
@ -166,37 +169,45 @@ do |
|
|
|
|
then |
|
|
|
|
# Generate drumset.h |
|
|
|
|
|
|
|
|
|
basename=`echo "${sample['filename']}" | cut -d'.' -f1` |
|
|
|
|
sox "${WAV_DIR}/${sample['filename']}" -c 1 -b 16 -L "${TMP}/${basename}.raw" |
|
|
|
|
xxd -i "${TMP}/${basename}.raw" > "${TMP}/${basename}.h" |
|
|
|
|
sample['len']=`grep "^unsigned int" "${TMP}/${basename}.h" | cut -d"=" -f2 | sed 's/\s*\([0-9]\+\);/\1/'` |
|
|
|
|
fill_mod=`expr "${sample['len']}" % "${AUDIO_BLOCK_SIZE}"` |
|
|
|
|
fill=`expr "${AUDIO_BLOCK_SIZE}" - "${fill_mod}"` |
|
|
|
|
sample['len']=`expr "${sample['len']}" + "${fill}"` |
|
|
|
|
sample['len']=`expr "${sample['len']}" / 2` |
|
|
|
|
|
|
|
|
|
echo "// Converted from ${sample['filename']}, length = ${sample['len']} bytes" >> "${DRUMSET_H}" |
|
|
|
|
echo "PROGMEM const int8_t ${sample['name']}[] = {" >> "${DRUMSET_H}" |
|
|
|
|
grep "^ " "${TMP}/${basename}.h" >> "${DRUMSET_H}" |
|
|
|
|
|
|
|
|
|
if (( "${fill}" > 0 )) |
|
|
|
|
if [ -z "${converted_files[${sample['filename']}]}" ] |
|
|
|
|
then |
|
|
|
|
echo -n "," >> "${DRUMSET_H}" |
|
|
|
|
fill_counter=0 |
|
|
|
|
for i in $(seq 1 "${fill}") |
|
|
|
|
do |
|
|
|
|
echo -n "0x00" >> "${DRUMSET_H}" |
|
|
|
|
let fill_counter+=1 |
|
|
|
|
if (( "${fill_counter}" >= 8 )) |
|
|
|
|
then |
|
|
|
|
echo "" >> "${DRUMSET_H}" |
|
|
|
|
fill_counter=0 |
|
|
|
|
else |
|
|
|
|
echo -n ", " >> "${DRUMSET_H}" |
|
|
|
|
fi |
|
|
|
|
done |
|
|
|
|
fi |
|
|
|
|
echo "};" >> /tmp/b |
|
|
|
|
basename=`echo "${sample['filename']}" | cut -d'.' -f1` |
|
|
|
|
sox "${WAV_DIR}/${sample['filename']}" -c 1 -b 16 -L "${TMP}/${basename}.raw" |
|
|
|
|
xxd -i "${TMP}/${basename}.raw" > "${TMP}/${basename}.h" |
|
|
|
|
sample['len']=`grep "^unsigned int" "${TMP}/${basename}.h" | cut -d"=" -f2 | sed 's/\s*\([0-9]\+\);/\1/'` |
|
|
|
|
fill_mod=`expr "${sample['len']}" % "${AUDIO_BLOCK_SIZE}"` |
|
|
|
|
fill=`expr "${AUDIO_BLOCK_SIZE}" - "${fill_mod}"` |
|
|
|
|
sample['len']=`expr "${sample['len']}" + "${fill}"` |
|
|
|
|
sample['len']=`expr "${sample['len']}" / 2` |
|
|
|
|
|
|
|
|
|
echo "// Converted from ${sample['filename']}, length = ${sample['len']} bytes" >> "${DRUMSET_H}" |
|
|
|
|
echo "PROGMEM const int8_t ${sample['name']}[] = {" >> "${DRUMSET_H}" |
|
|
|
|
grep "^ " "${TMP}/${basename}.h" >> "${DRUMSET_H}" |
|
|
|
|
|
|
|
|
|
if (( "${fill}" > 0 )) |
|
|
|
|
then |
|
|
|
|
echo -n "," >> "${DRUMSET_H}" |
|
|
|
|
fill_counter=0 |
|
|
|
|
for i in $(seq 1 "${fill}") |
|
|
|
|
do |
|
|
|
|
echo -n "0x00" >> "${DRUMSET_H}" |
|
|
|
|
let fill_counter+=1 |
|
|
|
|
if (( "${fill_counter}" >= 8 )) |
|
|
|
|
then |
|
|
|
|
echo "" >> "${DRUMSET_H}" |
|
|
|
|
fill_counter=0 |
|
|
|
|
else |
|
|
|
|
echo -n ", " >> "${DRUMSET_H}" |
|
|
|
|
fi |
|
|
|
|
done |
|
|
|
|
fi |
|
|
|
|
echo "};" >> "${DRUMSET_H}" |
|
|
|
|
|
|
|
|
|
converted_files["${sample['filename']}"]="${sample['name']},${sample['len']}" |
|
|
|
|
else |
|
|
|
|
sample['data_name']=`echo ${converted_files[${sample['filename']}]} | cut -d"," -f1` |
|
|
|
|
sample['len']=`echo ${converted_files[${sample['filename']}]} | cut -d"," -f2` |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
# Generate drums.h |
|
|
|
|
cat >> "${DRUMS_H}" << EOF |
|
|
|
@ -204,7 +215,7 @@ do |
|
|
|
|
${sample[class]}, |
|
|
|
|
${sample[midinote]}, |
|
|
|
|
"${sample[name]}", |
|
|
|
|
${sample[name]}, |
|
|
|
|
${sample[data_name]}, |
|
|
|
|
"${sample[shortname]}", |
|
|
|
|
${sample[len]}, |
|
|
|
|
${sample[pitch]}, |
|
|
|
|