Phatline Posted June 29, 2015 Report Posted June 29, 2015 (edited) Idea: it is inpired by the work of Andreas Körber and his "WortKraftSchwingung" Input: Midi notes Output1: DMX R-G-B values Destination1: RGBW-LED-PAR. Output2: LFO Audio Output 4 Bodyshacker a standart audio setup with a Midi-Sound-Synthesizer which is tuned to a specific frequency, a=430-445hz this tuning has to be set in the Converter-Software, because the converter gets only notes not frequencys... Hardware: switched to STM32F4 Stairville LEDPAR36 - RGBW-LED-PAR Converting Idea: is to octave the sound frequency as long we see it... since all octaves are sounding great...and some greater...the visible frequency then maybe also...and anyway - its a cool effect on stage. so what has to be calculated? we have hearable-sound-frequency in Herz [hz] we want to calculate the Visible color frequency in NanoMeter [nm] for example: 1. a note produce a sound of 100hz: float midi[127] = {}; //represent Midinote 0-127 - and its value is a Frequency in [hz] u32 actualnote = 69; // where 69 is A3 named A (which is tuned with "tuning" Variable above) s32 notecount = 0; // only a counter variable to calculate the note frequencys. float tuning = 431; //represent the tuning of "Kammerton A3" for (notecount = 0; notecount < 127; ++notecount) //calculte all 127 notes and frequencys {midi[notecount] = tuning * pow(2, (float)(notecount - 69)/12);} midi[actualnote] ///(=outputs the Frequency in [hz] for the actual played note 2. calculate the visible octave of 100hz & divide lightspeed by that frequency (hz*42th octave) / 10^12 =THz >>>> (100hz*2^42)/10^12 = 439.804THz lightspeed/THz=nm >>>> 299792,458/439.804 = 681.640nm float nm; long thz; thz = ( (midi[actualnote] * pow(2, 42) ) / 1000000000000); nm = 299792.458 / (float)thz; is the result not in the visible Spectrum > not between 790 and 390nm? whats then?::: i figured out that D2-D3 is the visible octave (midi nr 42 - 54) @431hz A3 tuning: F2=753nm, F3=376nm is it under 42? +12 notes until it is above or equal F2, how many octaves?>how many change the whithe LED-Level.... is it above 53? -12 notes until it is under or equal F3, how many octaves?>how many change the whithe LED-Level....::: //transpose the note to the visible Octave (NoteNr41-53) and save the octave Nr for further LED-White Parameters. octaveCOUNT = 4; //4 is the visible octave visiblenote = midinote; if (midinote < 42) {visiblenote = midinote + 12; --octaveCOUNT; // below visible octave? if (visiblenote < 42) {visiblenote = visiblenote + 12; --octaveCOUNT; if (visiblenote < 42) {visiblenote = visiblenote + 12; --octaveCOUNT; if (visiblenote < 42) {visiblenote = visiblenote + 12; --octaveCOUNT; }}}} if (midinote > 54) {visiblenote = midinote - 12; ++octaveCOUNT; //above visible octave if (visiblenote > 54) {visiblenote = visiblenote - 12; ++octaveCOUNT; if (visiblenote > 54) {visiblenote = visiblenote - 12; ++octaveCOUNT; if (visiblenote > 54) {visiblenote = visiblenote - 12; ++octaveCOUNT; if (visiblenote > 54) {visiblenote = visiblenote - 12; ++octaveCOUNT; if (visiblenote > 54) {visiblenote = visiblenote - 12; ++octaveCOUNT;}}}}}} 3. RGBW Calculation no matter which we use i have to offset the code with the real world the "RGB-LED-Spot" we cant speak of a exact octaved visible Light colour... but maybe we fade in a range +-hz so your mind find the correct colour itself....like a detuned unisono synth---there are frequencys sometimes that sounds great... the other thing is: Frequencys below 400 are UV... a UV-LED-DMX light would do the job... maybe i get me one once the dam DMX-Code thing is done. //MIX WHITE Light to the RGB, by using the Octaves, you may turn of that feature if you dont want. if (octaveCOUNT == 0) {RGBWnm[3] = 0;} else if (octaveCOUNT == 1) {RGBWnm[3] = 28;} else if (octaveCOUNT == 2) {RGBWnm[3] = 57;} else if (octaveCOUNT == 3) {RGBWnm[3] = 85;} else if (octaveCOUNT == 4) {RGBWnm[3] = 110;} else if (octaveCOUNT == 5) {RGBWnm[3] = 138;} else if (octaveCOUNT == 6) {RGBWnm[3] = 166;} else if (octaveCOUNT == 7) {RGBWnm[3] = 194;} else if (octaveCOUNT == 8) {RGBWnm[3] = 222;} else if (octaveCOUNT >= 9) {RGBWnm[3] = 255;} //WHITE OFFSET: RGBWdmx[3] = RGBWnm[3] -(RGBWenc[3]) ; //convert [nm] 2 [RGB] --- the GAMMA is not calculatet so - the colors @ end of spectrum are static...but they //have to fade out.... if (nm < 380) {RGBWnm[0] = 0; //if it is no visible spectrum RGBWnm[1] = 0; RGBWnm[2] = 12;} //a UV-Source has alternativly to be activated if (nm > 780) {RGBWnm[0] = 12; //a IR source has alternativly to be activated RGBWnm[1] = 0; RGBWnm[2] = 0;} else if (nm >= 380 && nm < 440) {RGBWnm[0] = ((-(nm - 440.) / (440. - 380.))*255); RGBWnm[1] = 0; RGBWnm[2] = 255;} else if (nm >= 440 && nm < 490) {RGBWnm[0] = 0; RGBWnm[1] = (( (nm - 440.) / (490. - 440.))*255); RGBWnm[2] = 255;} else if (nm >= 490 && nm < 510) {RGBWnm[0] = 0; RGBWnm[1] = 255; RGBWnm[2] = ((-(nm - 510.) / (510. - 490.))*255); } else if (nm >= 510 && nm < 580) {RGBWnm[0] = (( (nm - 510.) / (580. - 510.))*255); RGBWnm[1] = 255; RGBWnm[2] = 0;} else if (nm >= 580 && nm < 645) {RGBWnm[0] = 255; RGBWnm[1] = ((-(nm - 645.) / (645. - 580.))*255); RGBWnm[2] = 0;} else if (nm >= 645 && nm < 780) {RGBWnm[0] = 255; RGBWnm[1] = 0; RGBWnm[2] = 0;} } } 4. Sending DMX Values when we have the RGB-Values we send it via DMX to a RGB-LED, by adapting this code: http://svnmios.midibox.org/listing.php?repname=svn.mios32&path=%2Ftrunk%2Fapps%2Fexamples%2Fdmx%2F & studying this code: http://svnmios.midibox.org/filedetails.php?repname=svn.mios32&path=%2Ftrunk%2Fmodules%2Fdmx%2Fdmx.c void APP_Background(void){ //DMX: // endless loop while(1) { for (count=0;count<4;count++) { if (RGBWdmx[count]!=RGBWenc[count]) //if something has changed - send the value via DMX! { RGBWdmx[count]=RGBWenc[count]; DMX_SetChannel(count,(u8)RGBWdmx[count]);} } } } that was not the complicated thing... the complicatect comes now! Edited July 8, 2015 by Phatline
Phatline Posted July 6, 2015 Author Report Posted July 6, 2015 (edited) 5. DMX - Part NOT SOLVED YET the code which i cant compile if i activate the DMX functions: note2light-withDMX.zip Connect a 3 Pole- XLR-DMX-Connector to a LPC17 board: >>>J4B??? << I moved to STM32F4 Connect a 3 Pole- XLR-DMX-Connector to a STM32 board: >>>J4B??? do i need a IIC-Module? (RS485) >>> phil A other guy says that the voltage from lo to hi is a bit low... so it would only whith short cables... (a few meters...) is following pinout correct?: << I moved to STM32F4, but still dont know how to connect. under "dmx.h" there is the pinout for the DMX-Port definied: #define DMX_TX_PORT GPIOA #define DMX_TX_PIN GPIO_Pin_9 #define DMX_RX_PORT GPIOA #define DMX_RX_PIN GPIO_Pin_10 #define DMX USART1 #define DMX_IRQ_CHANNEL USART1_IRQn #define DMX_IRQHANDLER_FUNC void USART1_IRQHandler(void) The LPC17-core describtion says: <<<I moved to STM32F4 J4B A second IIC port, which can also be used as an additional MIDI IN/OUT port (MIDI IN4/OUT4) if enabled in MIOS32 (add "#define MIOS32_UART_NUM 4" to the mios32_config.h file). MIDI IN4 will be available on the J4B.SC. If a 6N138 based optocoupler circuit should be connected, replace the 2.2k pull-up R10 by 1k, or add a second 2.2k in parallel to get 1.1k effectively. MIDI OUT4 will be available on the J4B.SD pin, it isn't required to remove R9 if already soldered - it doesn't hurt. The STM32F4 core describtion says: J4B: Two IIC ports. Interface to BankSticks or to MBHP_IIC_* modules like MBHP_IIC_MIDI. I could use then J4B? > MIOS32_UART_NUM 4? dmx.h is talking about RX, TX while a 3pole-DMX-XLR-Connector is symetric: Mass and - and +. and do i have to change this lines to something like that?: #define DMX_TX_PORT GPIOA #define DMX_TX_PIN GPIO_Pin_10 #define DMX_RX_PORT GPIOA #define DMX_RX_PIN GPIO_Pin_11 #define DMX USART4 #define DMX_IRQ_CHANNEL USART4_IRQn #define DMX_IRQHANDLER_FUNC void USART4_IRQHandler(void) phils mios32 config: he disable uart...and disable with that midi of the whole board? can i workaround that? #ifndef _MIOS32_CONFIG_H #define _MIOS32_CONFIG_H #define MIOS32_DONT_USE_UART // For now disable UART as we will be using DMX #endif /* _MIOS32_CONFIG_H */ my mios32 config: i need midi becaue notes triggering events... ---disable uart4 by Assigment 0 make the same? or 2 > com? #ifndef _MIOS32_CONFIG_H #define _MIOS32_CONFIG_H #define MIOS32_USE_MIDI #define MIOS32_USE_UART #define MIOS32_USE_UART_MIDI #define MIOS32_UART_NUM 4 #define MIOS32_UART0_ASSIGNMENT 1 //1=Midi, 0= Disabled, 2= COM #define MIOS32_UART1_ASSIGNMENT 1 #define MIOS32_UART2_ASSIGNMENT 1 #define MIOS32_UART3_ASSIGNMENT 2 #endif /* _MIOS32_CONFIG_H */ Edited July 8, 2015 by Phatline
Phatline Posted July 8, 2015 Author Report Posted July 8, 2015 (edited) I use now STM32F4 ... but still compiling error the orginal DMX code was written for a STM32F1 (i think that was i read...) but that board i dont have @ home so i switched my setup to a CORE_STM32F4... in the hope that it would run on it... No it dont compile. how ever my test-code >>note2light-withDMX.zip << with the DMX-Parts activatet - which give me following compiling errors: make (im Verzeichnis: /home/tekkstar/c/note2light) rm -f project.hex Creating object file for app.c app.c:21:1: warning: 'bitband' attribute directive ignored [-Wattributes] } __attribute__((bitband)) my_struct; ^ Creating object file for dmx.c /home/tekkstar/mios32/trunk/modules/dmx/dmx.c: In function 'DMX_Init': /home/tekkstar/mios32/trunk/modules/dmx/dmx.c:65:34: error: 'GPIO_Mode_AF_PP' undeclared (first use in this function) GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; ^ /home/tekkstar/mios32/trunk/modules/dmx/dmx.c:65:34: note: each undeclared identifier is reported only once for each function it appears in /home/tekkstar/mios32/trunk/modules/dmx/dmx.c:69:34: error: 'GPIO_Mode_IPU' undeclared (first use in this function) GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; ^ Kompilierung fehlgeschlagen. /home/tekkstar/mios32/trunk/include/makefile/common.mk:160: recipe for target 'project_build//home/tekkstar/mios32/trunk/modules/dmx/dmx.o' failed make: *** [project_build//home/tekkstar/mios32/trunk/modules/dmx/dmx.o] Error 1 -for controll this is my code without DMX-Code in it:>> note2light-withoutDMX.zip<< by the way when i try to compile examples/dmx - code i got following compiling errors: make (im Verzeichnis: /home/tekkstar/mios32/trunk/apps/examples/dmx) rm -f project.hex Creating object file for startup_stm32f4xx.c Creating object file for mios32_bsl.c Creating object file for mios32_sys.c Creating object file for mios32_irq.c Creating object file for mios32_spi.c Creating object file for mios32_i2s.c Creating object file for mios32_board.c Creating object file for mios32_timer.c Creating object file for mios32_stopwatch.c Creating object file for mios32_delay.c Creating object file for mios32_ain.c /home/tekkstar/mios32/trunk/mios32/STM32F4xx/mios32_ain.c: In function 'DMA2_Stream0_IRQHandler': /home/tekkstar/mios32/trunk/mios32/STM32F4xx/mios32_ain.c:583:25: error: 'GPIO_TypeDef' has no member named 'BSRR' MIOS32_AIN_MUX0_PORT->BSRR = (mux_value & (1 << 0)) ? MIOS32_AIN_MUX0_PIN : (MIOS32_AIN_MUX0_PIN<<16); ^ /home/tekkstar/mios32/trunk/mios32/STM32F4xx/mios32_ain.c:586:25: error: 'GPIO_TypeDef' has no member named 'BSRR' MIOS32_AIN_MUX1_PORT->BSRR = (mux_value & (1 << 1)) ? MIOS32_AIN_MUX1_PIN : (MIOS32_AIN_MUX1_PIN<<16); ^ /home/tekkstar/mios32/trunk/mios32/STM32F4xx/mios32_ain.c:589:25: error: 'GPIO_TypeDef' has no member named 'BSRR' MIOS32_AIN_MUX2_PORT->BSRR = (mux_value & (1 << 2)) ? MIOS32_AIN_MUX2_PIN : (MIOS32_AIN_MUX2_PIN<<16); ^ Kompilierung fehlgeschlagen. /home/tekkstar/mios32/trunk/include/makefile/common.mk:160: recipe for target 'project_build//home/tekkstar/mios32/trunk/mios32/STM32F4xx/mios32_ain.o' failed make: *** [project_build//home/tekkstar/mios32/trunk/mios32/STM32F4xx/mios32_ain.o] Error 1 Edited July 8, 2015 by Phatline
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now