######################################################### # PROGRAMA PARA CONVERTIR DATOS EN SONIDO PARA SONIC-PI # ######################################################### # DATOS INICIALES ############################################################### # cero es nota base, g es factor para rango de cambio de notas entre min y max # tiempo es la base de duración de las pausas entre notas # file_data es el archivo con los números de la serie de datos en formato txt ################################################################################# cero=65 g=9 tiempo=0.5 file_data="C:\\uso_R\\sonic_pi\\TEMPERATURAS.txt" datos=readLines(file_data) total_datos=length(datos) line1=rep(" ",2*total_datos) datos_1=as.numeric(datos) min=as.numeric(min(datos)) max=as.numeric(max(datos)) alfa=g/(max-min) # A LOS VALORES SE ADJUDICA UN NUMERO DESDE LA NOTA BASE HASTA EL MAXIMO CON EL FACTOR ALFA ############################################################################################## notas=((datos_1)-min)*alfa notas=notas+cero notas=as.integer(notas) # CONVERSION DE DATOS ######## ############################## for (i in 1:total_datos) { posicion=(total_datos-i)+1 numero_nota=notas[posicion] line1[(i*2)-1]=paste("play",numero_nota,sep=" ") line1[(i*2)]=paste("sleep",tiempo,sep=" ") } ################################################################# write(line1,"c:\\uso_R\\sonic_pi\\melodia_datos_sonic.txt") ################################################################