Communication btw Propellers and mic-to-head object
I wanted to ask once more for help regarding a development project I am doing using the Propeller 1. I already posted two discussion in the past, but I have still a lot of unclear things to clarify due to my poor understanding of PASM (I am new to the job).
Let me start by giving you an understanding of my project:
For my university group, I am tasked to develop a way to have audio communication between two Propeller 1 Activity Boards. At the moment, I want to input, by microphone, voice into a Propeller 1 and have it come out through headphones connected to another Propeller 1, with a direct physical connection between them.
Here is how I am attacking the problem:
I firstly familiarized myself with the microphone to headphone object, with a few modifications (with help form the forum) and choosing the right mic, it works well and I am satisfied by the audio quality.
I then checked and fixed a PCM (13-bits) to A-law (8-bits) encoding script that was previously developed by my research group: the signal from the ADC part of the microphone to headphone object , is taken, encoded, decoded and output to the headphone after DAC. The conversion works well (I will push it in the GitHub once I have properly understood it).
At this point I would like to split the microphone to headphone object so that I talk into Propeller Activity Board (A) and output the audio from Propeller Activity Board (B). My idea to do this (and understand PASM on the way) is the following:
1) Modify the microphone to headphone object so that the output of the AD conversion (13-bit PCM put into a cog long register) is saved in the hub, picked later form the hub and used for the DA conversion.
2) Split the ADC and DAC PASM code so that two cogs run it in parallel, with the DAC picking the 13-bit PCM signal of the ADC form a shared hub register.
3) Check/modify already available SPI drivers to connect two Propeller Activity Boards together.
4) Make it so that the two Propeller Activity Boards (A) and (B), now connected through one SPI connection, have both two cogs running with a reciprocal continuous ADC and DAC: (A) does ADC (13-bit PCM) sends it in 32 bit package to the HUB of (B), the DAC cog of propeller (B) takes the 32-bit signal from the hub register and does DAC conversion on it, and vice versa.
I am already stuck at 1), as you can read it in the object I attached, I save the signal from the ADC to the hub and get it again for DAC two lines later, but I get a crazily distorted output from the headphones. I know that this is because of timing and sampling: I should probably sample the 13-bit PCM from the mic every "x" cycles, write it in the hub and use it "x" time for the DA conversion, but I have no idea how this works and how to start with the problem and can't really find any "clear" way to understand PASM fastly and figure it out.
Another alternative that I am considering for the project is to pair the propellers with a DAC (MCP3204) and DAC (MCP4921), this would make the implementation go down to establishing the SPI communications between the components, but I would like to develop this tool only using the Propeller 1.
Any help is greatly appreciated, I hope to understand PASM soon and be able to also participate and help in the discussion in a more meaningful way,