added: show now playing on display
This commit is contained in:
parent
d4e51b9e75
commit
6f5608bdb2
2 changed files with 398 additions and 1 deletions
395
src/bitvis.cpp
395
src/bitvis.cpp
|
@ -28,6 +28,7 @@
|
|||
#include <string>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -46,8 +47,21 @@ CBitVis::CBitVis(int argc, char *argv[])
|
|||
m_peakholds = NULL;
|
||||
m_nrbins = 1024;
|
||||
m_nrcolumns = 120;
|
||||
m_nrlines = 48;
|
||||
m_decay = 0.5;
|
||||
|
||||
m_fontheight = 0;
|
||||
for (int i = 0; i < 128; i++)
|
||||
{
|
||||
const unsigned int* dchar = GetChar(i);
|
||||
if (dchar)
|
||||
{
|
||||
int charheight = CharHeight(dchar);
|
||||
if (charheight > m_fontheight)
|
||||
m_fontheight = charheight;
|
||||
}
|
||||
}
|
||||
|
||||
m_nrlines = 48 - m_fontheight - 1;
|
||||
}
|
||||
|
||||
CBitVis::~CBitVis()
|
||||
|
@ -319,6 +333,29 @@ void CBitVis::SendData(int64_t time)
|
|||
data.SetData(line, sizeof(line), true);
|
||||
}
|
||||
|
||||
uint8_t text[m_nrcolumns / 4 * m_fontheight];
|
||||
memset(text, 0, sizeof(text));
|
||||
|
||||
AddText(text, "Now Playing");
|
||||
|
||||
//add an empty line
|
||||
data.SetData(text, m_nrcolumns / 4, true);
|
||||
|
||||
/*const unsigned int* dchar = GetChar('b');
|
||||
for (int i = 0; i < m_fontheight; i++)
|
||||
{
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
if (dchar[3 - j] & (1 << (m_fontheight - i - 1)))
|
||||
text[m_nrcolumns / 4 * i] |= 1 << (j * 2);
|
||||
|
||||
if (dchar[7 - j] & (1 << (m_fontheight - i - 1)))
|
||||
text[m_nrcolumns / 4 * i + 1] |= 1 << (j * 2);
|
||||
}
|
||||
}*/
|
||||
|
||||
data.SetData(text, sizeof(text), true);
|
||||
|
||||
uint8_t end[10];
|
||||
memset(end, 0, sizeof(end));
|
||||
data.SetData(end, sizeof(end), true);
|
||||
|
@ -332,6 +369,362 @@ void CBitVis::SendData(int64_t time)
|
|||
}
|
||||
}
|
||||
|
||||
void CBitVis::AddText(uint8_t* buff, const char* str)
|
||||
{
|
||||
int length = strlen(str);
|
||||
|
||||
for (int currchar = 0; currchar < length; currchar++)
|
||||
{
|
||||
const unsigned int* dchar = GetChar(str[currchar]);
|
||||
if (dchar)
|
||||
{
|
||||
for (int i = 0; i < m_fontheight; i++)
|
||||
{
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
if (dchar[3 - j] & (1 << (m_fontheight - i - 1)))
|
||||
buff[m_nrcolumns / 4 * i + currchar * 2] |= 1 << (j * 2);
|
||||
|
||||
if (dchar[7 - j] & (1 << (m_fontheight - i - 1)))
|
||||
buff[m_nrcolumns / 4 * i + 1 + currchar * 2] |= 1 << (j * 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const unsigned int* CBitVis::GetChar(char in)
|
||||
{
|
||||
static const char letter[] =
|
||||
{
|
||||
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
|
||||
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
|
||||
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ',', '.', '/',
|
||||
'<', '>', '?', ';', '\'', ':', '"', '[', ']', '\\', '{', '}', '|',
|
||||
'`', '-', '=', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(',
|
||||
')', '_', '+', ' '
|
||||
};
|
||||
|
||||
static const unsigned int letterData[][8] =
|
||||
{
|
||||
{
|
||||
0x18, 0xbc, 0xa4, 0xa4, 0xf8, 0x7c, 0x4,
|
||||
},
|
||||
{
|
||||
0x400, 0x7fc, 0x7fc, 0x84, 0xc4, 0x7c, 0x38,
|
||||
},
|
||||
{
|
||||
0x78, 0xfc, 0x84, 0x84, 0x84, 0xcc, 0x48,
|
||||
},
|
||||
{
|
||||
0x38, 0x7c, 0xc4, 0x484, 0x7f8, 0x7fc, 0x4,
|
||||
},
|
||||
{
|
||||
0x78, 0xfc, 0xa4, 0xa4, 0xa4, 0xec, 0x68,
|
||||
},
|
||||
{
|
||||
0x44, 0x3fc, 0x7fc, 0x444, 0x600, 0x300,
|
||||
},
|
||||
{
|
||||
0x72, 0xfb, 0x89, 0x89, 0x7f, 0xfe, 0x80,
|
||||
},
|
||||
{
|
||||
0x404, 0x7fc, 0x7fc, 0x40, 0x80, 0xfc, 0x7c,
|
||||
},
|
||||
{
|
||||
0x84, 0x6fc, 0x6fc, 0x4,
|
||||
},
|
||||
{
|
||||
0x6, 0x7, 0x1, 0x81, 0x6ff, 0x6fe,
|
||||
},
|
||||
{
|
||||
0x404, 0x7fc, 0x7fc, 0x20, 0x70, 0xdc, 0x8c,
|
||||
},
|
||||
{
|
||||
0x404, 0x7fc, 0x7fc, 0x4,
|
||||
},
|
||||
{
|
||||
0xfc, 0xfc, 0xc0, 0x78, 0xc0, 0xfc, 0x7c,
|
||||
},
|
||||
{
|
||||
0x80, 0xfc, 0x7c, 0x80, 0x80, 0xfc, 0x7c,
|
||||
},
|
||||
{
|
||||
0x78, 0xfc, 0x84, 0x84, 0x84, 0xfc, 0x78,
|
||||
},
|
||||
{
|
||||
0x81, 0xff, 0x7f, 0x89, 0x88, 0xf8, 0x70,
|
||||
},
|
||||
{
|
||||
0x70, 0xf8, 0x88, 0x89, 0x7f, 0xff, 0x81,
|
||||
},
|
||||
{
|
||||
0x84, 0xfc, 0x7c, 0xc4, 0x80, 0xe0, 0x60,
|
||||
},
|
||||
{
|
||||
0x48, 0xec, 0xa4, 0xb4, 0x94, 0xdc, 0x48,
|
||||
},
|
||||
{
|
||||
0x80, 0x80, 0x3f8, 0x7fc, 0x84, 0x8c, 0x8,
|
||||
},
|
||||
{
|
||||
0xf8, 0xfc, 0x4, 0x4, 0xf8, 0xfc, 0x4,
|
||||
},
|
||||
{
|
||||
0xf0, 0xf8, 0xc, 0xc, 0xf8, 0xf0,
|
||||
},
|
||||
{
|
||||
0xf8, 0xfc, 0xc, 0x38, 0xc, 0xfc, 0xf8,
|
||||
},
|
||||
{
|
||||
0x84, 0xcc, 0x78, 0x30, 0x78, 0xcc, 0x84,
|
||||
},
|
||||
{
|
||||
0xf1, 0xf9, 0x9, 0x9, 0xb, 0xfe, 0xfc,
|
||||
},
|
||||
{
|
||||
0xc4, 0xcc, 0x9c, 0xb4, 0xe4, 0xcc, 0x8c,
|
||||
},
|
||||
{
|
||||
0xfc, 0x1fc, 0x320, 0x620, 0x320, 0x1fc, 0xfc,
|
||||
},
|
||||
{
|
||||
0x404, 0x7fc, 0x7fc, 0x444, 0x444, 0x7fc, 0x3b8,
|
||||
},
|
||||
{
|
||||
0x1f0, 0x3f8, 0x60c, 0x404, 0x404, 0x60c, 0x318,
|
||||
},
|
||||
{
|
||||
0x404, 0x7fc, 0x7fc, 0x404, 0x60c, 0x3f8, 0x1f0,
|
||||
},
|
||||
{
|
||||
0x404, 0x7fc, 0x7fc, 0x444, 0x4e4, 0x60c, 0x71c,
|
||||
},
|
||||
{
|
||||
0x404, 0x7fc, 0x7fc, 0x444, 0x4e0, 0x600, 0x700,
|
||||
},
|
||||
{
|
||||
0x1f0, 0x3f8, 0x60c, 0x424, 0x424, 0x638, 0x33c,
|
||||
},
|
||||
{
|
||||
0x7fc, 0x7fc, 0x40, 0x40, 0x40, 0x7fc, 0x7fc,
|
||||
},
|
||||
{
|
||||
0x404, 0x7fc, 0x7fc, 0x404,
|
||||
},
|
||||
{
|
||||
0x18, 0x1c, 0x4, 0x404, 0x7fc, 0x7f8, 0x400,
|
||||
},
|
||||
{
|
||||
0x404, 0x7fc, 0x7fc, 0x40, 0x1f0, 0x7bc, 0x60c,
|
||||
},
|
||||
{
|
||||
0x404, 0x7fc, 0x7fc, 0x404, 0x4, 0xc, 0x1c,
|
||||
},
|
||||
{
|
||||
0x7fc, 0x7fc, 0x380, 0x1c0, 0x380, 0x7fc, 0x7fc,
|
||||
},
|
||||
{
|
||||
0x7fc, 0x7fc, 0x380, 0x1c0, 0xe0, 0x7fc, 0x7fc,
|
||||
},
|
||||
{
|
||||
0x1f0, 0x3f8, 0x60c, 0x404, 0x60c, 0x3f8, 0x1f0,
|
||||
},
|
||||
{
|
||||
0x404, 0x7fc, 0x7fc, 0x444, 0x440, 0x7c0, 0x380,
|
||||
},
|
||||
{
|
||||
0x3f0, 0x7f8, 0x408, 0x438, 0x41e, 0x7fe, 0x3f2,
|
||||
},
|
||||
{
|
||||
0x404, 0x7fc, 0x7fc, 0x440, 0x460, 0x7fc, 0x39c,
|
||||
},
|
||||
{
|
||||
0x318, 0x79c, 0x4c4, 0x444, 0x464, 0x73c, 0x318,
|
||||
},
|
||||
{
|
||||
0x700, 0x604, 0x7fc, 0x7fc, 0x604, 0x700,
|
||||
},
|
||||
{
|
||||
0x7f8, 0x7fc, 0x4, 0x4, 0x4, 0x7fc, 0x7f8,
|
||||
},
|
||||
{
|
||||
0x7e0, 0x7f0, 0x18, 0xc, 0x18, 0x7f0, 0x7e0,
|
||||
},
|
||||
{
|
||||
0x7f0, 0x7fc, 0x1c, 0x78, 0x1c, 0x7fc, 0x7f0,
|
||||
},
|
||||
{
|
||||
0x60c, 0x71c, 0x1f0, 0xe0, 0x1f0, 0x71c, 0x60c,
|
||||
},
|
||||
{
|
||||
0x780, 0x7c4, 0x7c, 0x7c, 0x7c4, 0x780,
|
||||
},
|
||||
{
|
||||
0x71c, 0x63c, 0x464, 0x4c4, 0x584, 0x70c, 0x61c,
|
||||
},
|
||||
{
|
||||
0x3f8, 0x7fc, 0x464, 0x4c4, 0x584, 0x7fc, 0x3f8,
|
||||
},
|
||||
{
|
||||
0x104, 0x304, 0x7fc, 0x7fc, 0x4, 0x4,
|
||||
},
|
||||
{
|
||||
0x20c, 0x61c, 0x434, 0x464, 0x4c4, 0x78c, 0x30c,
|
||||
},
|
||||
{
|
||||
0x208, 0x60c, 0x444, 0x444, 0x444, 0x7fc, 0x3b8,
|
||||
},
|
||||
{
|
||||
0x60, 0xe0, 0x1a0, 0x324, 0x7fc, 0x7fc, 0x24,
|
||||
},
|
||||
{
|
||||
0x7c8, 0x7cc, 0x444, 0x444, 0x444, 0x47c, 0x438,
|
||||
},
|
||||
{
|
||||
0x1f8, 0x3fc, 0x644, 0x444, 0x444, 0x7c, 0x38,
|
||||
},
|
||||
{
|
||||
0x600, 0x600, 0x43c, 0x47c, 0x4c0, 0x780, 0x700,
|
||||
},
|
||||
{
|
||||
0x3b8, 0x7fc, 0x444, 0x444, 0x444, 0x7fc, 0x3b8,
|
||||
},
|
||||
{
|
||||
0x380, 0x7c4, 0x444, 0x444, 0x44c, 0x7f8, 0x3f0,
|
||||
},
|
||||
{
|
||||
0x4, 0x3c, 0x38,
|
||||
},
|
||||
{
|
||||
0x18, 0x18,
|
||||
},
|
||||
{
|
||||
0x30, 0x60, 0xc0, 0x180, 0x300, 0x600, 0xc00,
|
||||
},
|
||||
{
|
||||
0x80, 0x1c0, 0x360, 0x630, 0xc18, 0x808,
|
||||
},
|
||||
{
|
||||
0x808, 0xc18, 0x630, 0x360, 0x1c0, 0x80,
|
||||
},
|
||||
{
|
||||
0x600, 0xe00, 0x800, 0x8d8, 0x9d8, 0xf00, 0x600,
|
||||
},
|
||||
{
|
||||
0x8, 0x638, 0x630,
|
||||
},
|
||||
{
|
||||
0x200, 0x1e00, 0x1c00,
|
||||
},
|
||||
{
|
||||
0x630, 0x630,
|
||||
},
|
||||
{
|
||||
0x1c00, 0x1e00, 0x0, 0x0, 0x1e00, 0x1c00,
|
||||
},
|
||||
{
|
||||
0xff8, 0xff8, 0x808, 0x808,
|
||||
},
|
||||
{
|
||||
0x808, 0x808, 0xff8, 0xff8,
|
||||
},
|
||||
{
|
||||
0xe00, 0x700, 0x380, 0x1c0, 0xe0, 0x70, 0x38,
|
||||
},
|
||||
{
|
||||
0x80, 0x80, 0x7f0, 0xf78, 0x808, 0x808,
|
||||
},
|
||||
{
|
||||
0x808, 0x808, 0xf78, 0x7f0, 0x80, 0x80,
|
||||
},
|
||||
{
|
||||
0xf78, 0xf78,
|
||||
},
|
||||
{
|
||||
0x3000, 0x3800, 0x800,
|
||||
},
|
||||
{
|
||||
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
||||
},
|
||||
{
|
||||
0x120, 0x120, 0x120, 0x120, 0x120, 0x120,
|
||||
},
|
||||
{
|
||||
0x400, 0xc00, 0x800, 0xc00, 0x400, 0xc00, 0x800,
|
||||
},
|
||||
{
|
||||
0x700, 0xfd8, 0xfd8, 0x700,
|
||||
},
|
||||
{
|
||||
0x7f0, 0xff8, 0x808, 0x9e8, 0x9e8, 0xfe8, 0x7c0,
|
||||
},
|
||||
{
|
||||
0x220, 0xff8, 0xff8, 0x220, 0xff8, 0xff8, 0x220,
|
||||
},
|
||||
{
|
||||
0x730, 0xf98, 0x888, 0x388e, 0x388e, 0xcf8, 0x670,
|
||||
},
|
||||
{
|
||||
0x308, 0x318, 0x30, 0x60, 0xc0, 0x198, 0x318,
|
||||
},
|
||||
{
|
||||
0x400, 0xc00, 0x1800, 0x3000, 0x1800, 0xc00, 0x400,
|
||||
},
|
||||
{
|
||||
0x70, 0x6f8, 0xf88, 0x9c8, 0xf70, 0x6f8, 0x88,
|
||||
},
|
||||
{
|
||||
0x80, 0x2a0, 0x3e0, 0x1c0, 0x1c0, 0x3e0, 0x2a0, 0x80,
|
||||
},
|
||||
{
|
||||
0x3e0, 0x7f0, 0xc18, 0x808,
|
||||
},
|
||||
{
|
||||
0x808, 0xc18, 0x7f0, 0x3e0,
|
||||
},
|
||||
{
|
||||
0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2,
|
||||
},
|
||||
{
|
||||
0x80, 0x80, 0x3e0, 0x3e0, 0x80, 0x80,
|
||||
},
|
||||
{
|
||||
0x0, 0x0, 0x0,
|
||||
},
|
||||
};
|
||||
|
||||
assert((sizeof(letter) / sizeof(letter[0])) <= (sizeof(letterData) / sizeof(letterData[0])));
|
||||
|
||||
for (size_t i = 0; i < sizeof(letter) / sizeof(letter[0]); i++)
|
||||
{
|
||||
if (letter[i] == in)
|
||||
return letterData[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int CBitVis::CharHeight(const unsigned int* in)
|
||||
{
|
||||
int highest = 0;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
for (int j = 0; j < 32; j++)
|
||||
{
|
||||
if (in[i] & (1 << j))
|
||||
{
|
||||
if (highest < j + 1)
|
||||
highest = j + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return highest;
|
||||
}
|
||||
|
||||
void CBitVis::JackError(const char* jackerror)
|
||||
{
|
||||
LogDebug("%s", jackerror);
|
||||
|
|
|
@ -48,6 +48,7 @@ class CBitVis
|
|||
int m_nrcolumns;
|
||||
int m_nrlines;
|
||||
float m_decay;
|
||||
int m_fontheight;
|
||||
|
||||
struct peak
|
||||
{
|
||||
|
@ -63,6 +64,9 @@ class CBitVis
|
|||
void ProcessSignalfd();
|
||||
void ProcessAudio();
|
||||
void SendData(int64_t time);
|
||||
void AddText(uint8_t* buff, const char* str);
|
||||
const unsigned int* GetChar(char in);
|
||||
int CharHeight(const unsigned int* in);
|
||||
static void JackError(const char* jackerror);
|
||||
static void JackInfo(const char* jackinfo);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue