mus 174b – assignment 1

1) record new material, 6-12 tracks:  between 2 and 4 minutes
2) make several inaudible edits
3) one or more of the tracks should be vocal
4) the rest of the tracks can be computer or electronic (synths, drum machine, pd, max/msp, looped samples, noise, etc.). no premixed backing tracks
5) all electronic tracks should have track effects (plugins) to give them unique identity using eq or reverb
6) create 2 different mixes which gives a different sense of foreground, width and depth
7) create width with panning
8) establish foreground instruments with volume differences and eq
9) create width and depth with reverb/mic distance
10) separate the tracks into 3 or more groups, route the groups into 3 or more aux input tracks, mix aux tracks for final mix
11) apply fade-in and fade-out to final stereo mixes
12) leave session and mix files on class disk (174B folder, project name with your last names)

present in class on 2-1-18 or 2-6-18 (thurs. wk4, tues. wk5)


Cory Jonathan Banh – Francis Kyle Galang – Matthew Harrison Rice
Christopher Patrick Loree – Jorge Alberto Jiron Villarreal – William Joseph-Glen Carlisle
Raymond S Lim – Daniela Andrea Chaparro – Gregory Tazmond Farley
Chloe Jessica Bari – Kenroe Ervin Ang – John Anthony D’Agostini
Yidai Li – Grant Parker Hovander – Kostyantyn Chumakov
Caleb Michael Hess – James Forest Reid – Camden Robert Greenwood
Chi Zhang – Tracy Nicole Levick – Salvador Zamora
Jacob Michael Ugalde – Crystal Jiao – Cordane Omari Richardson

MUS177/267 full duplex audio 1

Gettinng full duplex audio to work on the discovery boards is tricky, as they were not designed to do this. We will dig deep into the hardware configuration to find some work-arounds.


This board has no high fidelity line audio in, so cannot be used for high fidelity full duplex audio. However, it does have many 12 bit ADC inputs and 2 12 bit DAC outputs.

To get an ADC and DAC to work together, they have to be synchronized. In my example code we will use a timer set at 48000 Hz to clock both. We also need a timer which can be used for both the ADC and DAC. If you look at the ADC HAL header file, you will see the following:

/** @defgroup ADC_External_trigger_Source_Regular ADC External Trigger Source Regular  
* @{
/* Note: Parameter ADC_SOFTWARE_START is a software parameter used for        */
/*       compatibility with other STM32 devices.                              */
#define ADC_EXTERNALTRIGCONV_T1_CC1    ((uint32_t)0x00000000U)
#define ADC_EXTERNALTRIGCONV_T1_CC2    ((uint32_t)ADC_CR2_EXTSEL_0)
#define ADC_EXTERNALTRIGCONV_T1_CC3    ((uint32_t)ADC_CR2_EXTSEL_1)
#define ADC_EXTERNALTRIGCONV_T2_CC2    ((uint32_t)(ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
#define ADC_EXTERNALTRIGCONV_T2_CC3    ((uint32_t)ADC_CR2_EXTSEL_2)
#define ADC_EXTERNALTRIGCONV_T2_CC4    ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_0))
#define ADC_EXTERNALTRIGCONV_T4_CC4    ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_0))
#define ADC_EXTERNALTRIGCONV_T5_CC1    ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_1))
#define ADC_EXTERNALTRIGCONV_T5_CC3    ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2))

And in the DAC HAL header we see:

/** @defgroup DAC_trigger_selection DAC Trigger Selection
  * @{
#define DAC_TRIGGER_NONE                   ((uint32_t)0x00000000U) /*!< Conversion is automatic once the DAC1_DHRxxxx register has been loaded, and not by external trigger */
#define DAC_TRIGGER_T2_TRGO                ((uint32_t)(DAC_CR_TSEL1_2 | DAC_CR_TEN1)) /*!< TIM2 TRGO selected as external conversion trigger for DAC channel */
#define DAC_TRIGGER_T4_TRGO                ((uint32_t)(DAC_CR_TSEL1_2 | DAC_CR_TSEL1_0 | DAC_CR_TEN1)) /*!< TIM4 TRGO selected as external conversion trigger for DAC channel */
#define DAC_TRIGGER_T5_TRGO                ((uint32_t)(DAC_CR_TSEL1_1 | DAC_CR_TSEL1_0 | DAC_CR_TEN1)) /*!< TIM5 TRGO selected as external conversion trigger for DAC channel */
#define DAC_TRIGGER_T6_TRGO                ((uint32_t)DAC_CR_TEN1) /*!< TIM6 TRGO selected as external conversion trigger for DAC channel */
#define DAC_TRIGGER_T7_TRGO                ((uint32_t)(DAC_CR_TSEL1_1 | DAC_CR_TEN1)) /*!< TIM7 TRGO selected as external conversion trigger for DAC channel */
#define DAC_TRIGGER_T8_TRGO                ((uint32_t)(DAC_CR_TSEL1_0 | DAC_CR_TEN1)) /*!< TIM8 TRGO selected as external conversion trigger for DAC channel */

Timer 2 and 8 trigger output are in common for both ADC and DAC. In my example I will use timer 8. Look at functions timer8_init(), adc1_init() and dac1_init() for details.

Finally, notice that in the audio callback I am copying and scaling the input first, then processing audio (an echo in this case), and finally copying and scaling the output. Also, both input and output can be processed in the DAC callback. No need to do it in the ADC callback as they are synchronized by the same clock.

void HAL_DAC_ConvHalfCpltCallbackCh1(DAC_HandleTypeDef* DacHandle)
  int i,j;
  for(i = 0, j = 0; i < 16; i++, j+=2)
    inBuffer[i] = inBuffer[i+1] = (float)(adcBuffer[i] * 0.00048828125f) - 1.0f;
  audioBlock(inBuffer, outBuffer, 16);
  for(i = 0, j = 0; i < 16; i++, j+=2)
    dacBuffer[i] = (int16_t)((outBuffer[j] + outBuffer[j+1] + 2.0f) * 1023.0f);

Here is the example code:



The BSP code supplied with the board is inadequate as it doesn’t allow the line in to be used. I have found a developer who modified the code to do full duplex input and output, but I have yet to try it myself. I will do so by next Thursday. The code is here:

MUS174A – 3rd assignment

assignment #3 – music 174a

the idea of this project is to record at least 3 different instruments (a drum kit is considered a single instrument) with microphones to create a complete recording of a piece or song. quality counts. strive for fullness and detail.

3-5 minute piece

1 use at least 3 different microphones

2 majority of tracks should be miked (some electronic instruments allowed)

3 use close and distant miking

4 make at least two overdubs

5 at least 5 edits, and at least 10 tracks

6 do a basic rough mix

no effects or plugins with the following exception:
– acoustic effects can be used (hallway reverb, room mic, etc.)

you must present your piece in 10th or finals week, playing the piece, explaining what you did and answering questions.
you should place the session in the 174a folder, with a separate stereo interleaved soundfile with the final edit/rough mix.

you should also hand in documentation as follows:
– microphone/instrument diagram
– track listing with mic, settings
– take listing with time, description, notes

work in the following groups

Grant Parker Hovander – James Forest Reid – Tracy Nicole Levick
Crystal Jiao – Matthew Harrison Rice – Joyce Hwayoung Park
William Joseph-Glen Carlisle – Gregory Tazmond Farley
John Anthony D’Agostini – Kostyantyn Chumakov – Aldo Marcel Mojica
Camden Robert Greenwood – Salvador Zamora – Cordane Omari Richardson
Cory Jonathan Banh – Christopher Patrick Loree
Raymond S Lim – Chloe Jessica Bari – Yidai Li
Camille Angela Latzke – Caleb Michael Hess – Chi Zhang
Jacob Michael Ugalde – Francis Kyle Galang – Jorge Alberto Jiron Villarreal
Daniela Andrea Chaparro – Kenroe Ervin Ang – Lizbeth Rios

MUS177/267 – Sample Playback & “Moog” Filter

Here is the project from today’s class. Sample playback simply requires creating a pointer to the samples at the address used in FLASH (0x08080000 in this case), creating an offset for the first sample played, and incrementing this value until reaching the last sample to be played.


To write samples in the STM32F4 FLASH (we will write in the second half of FLASH from 0x08080000 to 0x080FFFFE)

  1. prepare a sound file by making it a 16 bit mono WAV at 48k sample rate
  2. there are only 524288 bytes, so limit the sample to 262144 samples or 5.4 seconds
  3. save the sample
  4. using Hexfiend, strip off the WAV header (everything up to the word ‘data’ and the 4 bytes after that)
  5. save as a new file with the suffix “.bin”
  6. alternatively open WAV with SoundHack and save as Headerless, 16bit byte swap and “.bin” suffix
  7. make sure OpenOCD is running and connected to your board
  8. use telnet in a terminal window to connect to OpenOCD – “telnet localhost 4444″
  9. make sure STM32F4 is halted with “reset halt”
  10. write into FLASH with command “flash write_image erase filename.bin 0x08080000″
  11. restart your programs with “reset run”