Prep before md work.

This commit is contained in:
jmsgrogan 2020-05-09 09:35:09 +01:00
parent 4d5ca4d654
commit 875cdc84ff
2 changed files with 47 additions and 49 deletions

View file

@ -94,7 +94,6 @@ void AlsaInterface::SetPeriod(AudioDevicePtr device)
void AlsaInterface::SetBufferSize(AudioDevicePtr device)
{
snd_pcm_uframes_t periodsize = 8192; /* Periodsize (bytes) */
int periods = static_cast<int>(device->GetPeriod());
/* Set buffer size (in frames). The resulting latency is given by */
@ -119,15 +118,14 @@ void AlsaInterface::SetChannelNumber(AudioDevicePtr device)
void AlsaInterface::Play(AudioDevicePtr device)
{
MLOG_INFO("Playing audio");
int num_frames = 10;
unsigned char *data = (unsigned char *)malloc(mPeriodSize);
int frames = mPeriodSize >> 2;
for(int l1 = 0; l1 < 100; l1++)
for(int count = 0; count < 100; count++)
{
for(int l2 = 0; l2 < num_frames; l2++)
for(int l2 = 0; l2 < frames; l2++)
{
short s1 = (l2 % 128) * 100 - 5000;
short s2 = (l2 % 256) * 100 - 5000;
short s1 = (l2 % (512-count)) * 100 - 5000;
short s2 = (l2 % (256-count)) * 100 - 5000;
data[4*l2] = (unsigned char)s1;
data[4*l2+1] = s1 >> 8;
data[4*l2+2] = (unsigned char)s2;

View file

@ -34,11 +34,11 @@ void MainApplication::RunServer()
void MainApplication::PlayAudio()
{
MidiReader reader;
reader.Read("/home/james/sample.mid");
// auto device = AudioDevice::Create();
// mAudioManager->GetAudioInterface()->OpenDevice(device);
// mAudioManager->GetAudioInterface()->Play(device);
//MidiReader reader;
//reader.Read("/home/james/sample.mid");
auto device = AudioDevice::Create();
mAudioManager->GetAudioInterface()->OpenDevice(device);
mAudioManager->GetAudioInterface()->Play(device);
}
void MainApplication::ShutDown()