LABSN / tdtpy

Python wrapper around the Tucker-Davis Technologies ActiveX library
BSD 3-Clause "New" or "Revised" License
7 stars 3 forks source link

Buffer not recognizing tag #24

Open bscoventry opened 1 year ago

bscoventry commented 1 year ago

Hi all,

I've been using TDTPy successfully for the last few years, but have run into a strange problem. On running the test program included using the 'record_microphone.rcx' circuit, I get the following error at speaker_buffer = circuit.get_buffer('speaker', 'w'): ValueError: size tag for RZ6:record_microphone.rcx:CxLdRn:speaker must be present in circuit I then used the circuit.tags method and found that speaker is seen as a vector input. Looks good. Running the activeX code, I can also successfully write the sin to the speaker buffer. Do you have any thoughts on what might be causing this? For reference, I've attached the exact code I'm running.

from numpy import arange, sin, pi
  from tdt import DSPProject, DSPError
  import pdb
  if __name__ == "__main__":
    try:
            # Load the circuit
            project = DSPProject()
            circuit = project.load_circuit('record_microphone.rcx', 'RZ6')
            circuit.start()

            # Configure the data tags
            circuit.cset_tag('record_del_n', 25, 'ms', 'n')
            circuit.cset_tag('record_dur_n', 500, 'ms', 'n')
            pdb.set_trace()
            # Compute and upload the waveform
            t = arange(0, 1, circuit.fs**-1)
            waveform = sin(2*pi*1e3*t)
            speaker_buffer = circuit.get_buffer('speaker', 'w')
            speaker_buffer.write(waveform)

            # Acquire the microphone data
            microphone_buffer = circuit.get_buffer('mic', 'r')
            data = microphone_buffer.acquire(1, 'running', False)
        except DSPError:
            print("Error acquiring data: {}")
bburan commented 1 year ago

What version of TDTPy are you using?

On Mon, Jan 16, 2023, 12:27 PM Brandon Coventry @.***> wrote:

Hi all,

I've been using TDTPy successfully for the last few years, but have run into a strange problem. On running the test program included using the 'record_microphone.rcx' circuit, I get the following error at speaker_buffer = circuit.get_buffer('speaker', 'w'): ValueError: size tag for RZ6:record_microphone.rcx:CxLdRn:speaker must be present in circuit I then used the circuit.tags method and found that speaker is seen as a vector input. Looks good. Running the activeX code, I can also successfully write the sin to the speaker buffer. Do you have any thoughts on what might be causing this? For reference, I've attached the exact code I'm running. `from numpy import arange, sin, pi from tdt import DSPProject, DSPError import pdb if name == 'main': try:

Load the circuit

project = DSPProject() circuit = project.load_circuit('record_microphone.rcx', 'RZ6') circuit.start()

  # Configure the data tags
  circuit.cset_tag('record_del_n', 25, 'ms', 'n')
  circuit.cset_tag('record_dur_n', 500, 'ms', 'n')
  pdb.set_trace()
  # Compute and upload the waveform
  t = arange(0, 1, circuit.fs**-1)
  waveform = sin(2*pi*1e3*t)
  speaker_buffer = circuit.get_buffer('speaker', 'w')
  speaker_buffer.write(waveform)

  # Acquire the microphone data
  microphone_buffer = circuit.get_buffer('mic', 'r')
  data = microphone_buffer.acquire(1, 'running', False)

except DSPError: print("Error acquiring data: {}")

`

— Reply to this email directly, view it on GitHub https://github.com/LABSN/tdtpy/issues/24, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACPSQSX2SAOGG26RRHP7NDWSWVMTANCNFSM6AAAAAAT5DWZPQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

bscoventry commented 1 year ago

Hi! I am using version 0.10.0

bburan commented 1 year ago

Ok, thanks for the clarification.

It's been years since I looked at that particular circuit and I can't remember whether it actually worked or not. For example, the SerSource and SerStore are missing a speaker_n and mic_n tag which need to be linked to the size ports. This lets TDTPy inspect the circuit and figure out how many samples can be written/read from these. See the documentation for DSPBuffer (https://tdtpy.readthedocs.io/en/latest/dsp_buffer.html).

TDTPy has always supported continuous (streaming) reads from SerStore buffers (provided you have all the correct tags hooked up). However, I recently updated TDTPy to support continuous (streaming) writes to SerSource as well. I did my best to keep backwards compatibility in place. It's possible I broke something.

Can you give me a more specific example of why you are reporting this issue. Do you usually use that test code in the original post with every version of TDTPy, or did you whip it up because you were having trouble with the latest release? If so, can you spell out in more detail what exactly the issue is?

Alternatively, can you verify that the example script you write works on an earlier version of TDTPy?

drammock commented 1 year ago

Hi! I am using version 0.10.0

there is no version 0.10.0? 😕 https://github.com/LABSN/tdtpy/releases

bburan commented 1 year ago

I haven't been making releases to Github. They are available on PyPI though (e.g., https://pypi.org/project/TDTPy/0.10.0/) and also see the Git tags in this repo.

bburan commented 1 year ago

@drammock Is there any value to creating releases on Github?

drammock commented 1 year ago

@drammock Is there any value to creating releases on Github?

Eh, sort of. People do look there for releases sometimes (as I just did). The tags are more important probably.

it's possible to have a GitHub action automatically build wheels and upload them to pypi each time you make a release, which eliminate the double effort (but I think it's a bit tricky to set up... @larsoner has done it I think)

bburan commented 1 year ago

@bscoventry I do believe you if you are stating there's an issue with TDTPy, but I need a little more information before I can advise and or fix the issue. For example, I have made TDTPy a bit more strict about the circuit design and what supporting tags must be present in the circuit to enable the streaming reads/writes. This could conceivably have broken code that did not have all the supporting tags present. I'm fleshing out the unit-test library (which was quite sparse before), so it would be good to know exactly what broke so we can incorporate that into our unit-tests.

I'm assuming that you found that a newer release of TDTPy does not work, so you tried the example circuit included in the documentation and found that did not work. I agree that we should have a working example circuit and script, but what I'm more interested in at this point is what specifically broke in your own code so we can fix that.