Skip to content

Commit

Permalink
update tx
Browse files Browse the repository at this point in the history
  • Loading branch information
paulh002 committed Jun 28, 2022
1 parent 0f108e3 commit 9973d91
Show file tree
Hide file tree
Showing 44 changed files with 134,604 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ bld/
[Oo]ut/
[Ll]og/
[Ll]ogs/
Archive/

# Visual Studio 2015/2017 cache/options directory
.vs/
Expand Down
Binary file modified .visualgdb/CodeDB/SoapyHifiBerry-Release-VisualGDB/AudioInput.rdb
Binary file not shown.
Binary file not shown.
Binary file modified .visualgdb/CodeDB/SoapyHifiBerry-Release-VisualGDB/AudioOutput.npd
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
This file was last opened by PID 19252
This file was last opened by PID 19364
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified .visualgdb/CodeExplorer/NodeFlags.dat
Binary file not shown.
Binary file not shown.
9 changes: 5 additions & 4 deletions AudioOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
* A underrun counter is increased for adjusting samplerate of the radio
**/

const int audio_buffer_size{2024};

int Audioout( void *outputBuffer,void *inputBuffer,unsigned int nBufferFrames,double streamTime,RtAudioStreamStatus status, void *userData)
{
double *buffer = (double *) outputBuffer;
IQSample *buffer = (IQSample *) outputBuffer;

if (status)
std::cout << "Stream underflow detected!\n" << std::endl;
Expand All @@ -21,7 +22,7 @@ int Audioout( void *outputBuffer,void *inputBuffer,unsigned int nBufferFrames,do
{
for (int i = 0; i < nBufferFrames; i++)
{
((IQSample *)buffer)[i] = 0.0;
buffer[i] = IQSample(0,0);
}
return 0;
}
Expand Down Expand Up @@ -86,7 +87,7 @@ AudioOutput::AudioOutput(int pcmrate, DataBuffer<IQSample> *AudioBuffer, RtAudio
{
m_sampleRate = pcmrate;
databuffer = AudioBuffer;
bufferFrames = 1024;
bufferFrames = audio_buffer_size;
parameters.nChannels = 2;
parameters.firstChannel = 0;
parameters.deviceId = 0;
Expand Down Expand Up @@ -126,7 +127,7 @@ bool AudioOutput::open(std::string device)
alsa_device = parameters.deviceId - 1;
parameters.nChannels = info.outputChannels;
printf("audio device = %d %s samplerate %d channels %d\n", parameters.deviceId, device.c_str(), m_sampleRate, parameters.nChannels);
err = this->openStream(&parameters, NULL, RTAUDIO_FLOAT64, m_sampleRate, &bufferFrames, &Audioout, (void *)databuffer, NULL);
err = this->openStream(&parameters, NULL, RTAUDIO_FLOAT32, m_sampleRate, &bufferFrames, &Audioout, (void *)databuffer, NULL);
if (err != RTAUDIO_NO_ERROR)
{
printf("Cannot open audio output stream\n");
Expand Down
2 changes: 2 additions & 0 deletions AudioOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include "Audiodefs.h"
#include "DataBuffer.h"

extern const int audio_buffer_size;

class AudioOutput :
public RtAudio
{
Expand Down
2 changes: 1 addition & 1 deletion SoapyHifiBerrySettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ SoapyHifiBerry::SoapyHifiBerry(const SoapySDR::Kwargs &args)
pSI5351->drive_strength(CLK_VFO_RX, SI5351_DRIVE_2MA);
pSI5351->drive_strength(CLK_VFO_TX, SI5351_DRIVE_2MA);
pSI5351->output_enable(CLK_VFO_RX, 1);
pSI5351->output_enable(CLK_VFO_TX, 0);
pSI5351->output_enable(CLK_VFO_TX, 1);
pSI5351->output_enable(CLK_NA, 0);
pSI5351->set_freq(2916800000ULL, CLK_VFO_RX);
pSI5351->update_status();
Expand Down
5 changes: 3 additions & 2 deletions SoapyHifiBerryStreaming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ int SoapyHifiBerry::readStream(
return (nr_samples); //return the number of IQ samples
}

IQSampleVector iqsamples;

int SoapyHifiBerry::writeStream(SoapySDR::Stream *handle, const void *const *buffs, const size_t numElems, int &flags, const long long timeNs, const long timeoutUs)
{
Expand All @@ -179,15 +180,15 @@ int SoapyHifiBerry::writeStream(SoapySDR::Stream *handle, const void *const *buf
void const *buff_base = buffs[0];
IQSample *target_buffer = (IQSample *)buff_base;
sdr_stream *ptr = (sdr_stream *)handle;
IQSampleVector iqsamples;

if (ptr->get_stream_format() == HIFIBERRY_SDR_CF32)
{
for (int i = 0; i < numElems; i++)
{
iqsamples.push_back(target_buffer[i]);
if (iqsamples.size() == audio_buffer_size)
uptr_audiooutput->write(iqsamples);
}
uptr_audiooutput->write(iqsamples);
}
return numElems;
}
Loading

0 comments on commit 9973d91

Please sign in to comment.