While loop resets a numeric variable in a Bash script [duplicate]

Do not use the pipe, it creates a subshell. Example below.

#!/bin/bash
declare -i AUX=0
while IFS='' read -r -d '' file; do
    ### DO SOMETHING with $file###
    (( ++AUX ))
    echo $AUX
done < <(find . -type "f" -name "*.mp3")
echo $AUX