sdl

【音视频连载-007】基础学习篇-SDL 播放 PCM 音频文件(上)

為{幸葍}努か 提交于 2021-02-16 16:26:34
公众号回复:OpenGL,领取学习资源大礼包 音视频学习入门技术文章连载: 技术开发故事会连载 【音视频连载-001】基础学习篇-SDL 介绍以及工程配置 【音视频连载-002】基础学习篇-SDL 创建窗口并显示颜色 【音视频连载-003】基础学习篇-SDL 消息循环和事件响应 【音视频连载-004】基础学习篇-SDL 加载图片并显示 【音视频连载-005】基础学习篇-SDL 加载 YUV 文件并显示 【音视频连载-006】基础学习篇-SDL 播放 YUV 视频文件 在前面的文章中已经能够利用 SDL 去播放 YUV 视频文件了,接下来要通过 SDL 去播放 PCM 音频文件。 SDL 播放音频文件有两种方法,可以理解成 推(push) 和 拉(pull) 两种模式。 推 就是我们主动向设备缓冲区填充 Buffer ,而 拉 就是由设备拉取 Buffer 填充到缓冲区。 在一些开发模型中,如果数据传递能够抽象成 流 的形式,那么肯定就会有 推 和 拉 两种模式。 本篇文章主要是讲解 SDL 以推的形式播放音频文件。 PCM 文件素材准备 首先还是得准备素材,做音视频相关实验就是这么麻烦~~ 找一个 mp3 文件,使用 FFmpeg 命令将它转换成 pcm 文件,方便的话可以直接使用代码仓库提供的 mp3 文件。 不像在视频播放中准备素材那样简单,音频文件对于参数的信息要求多一点

sdl2播放网络音频直播pcm播放pcm音频流

本秂侑毒 提交于 2021-02-16 13:07:43
音频直播服务是叫做 LANmic 无线话筒 的安卓程序。 访问http://192.168.1.8:8080 就能播放了。可以网页播放,vlc,ffmpeg, 那么我sdl能不能播放呢?LANmic 提供了wav编码,可以直接pcm播放。 经过搜索,发现搜到的文章都是一大抄,各种转,都是一样的,sdl本地文件播放,让人头大,无奈只好自己分析方法了。 经过抓包,我发现访问http://192.168.1.8:8080 返回的是http头,后续就是riff wavefmt 搞过wav格式的都知道,这个wav头了 那么我们把http头跳过,读取后面的wav头以及数据,就可以播放了。 经过调试,代码如下 #include <stdio.h> #include <tchar.h> #include "SDL.h" #include "sockutil.h" #pragma comment(lib, "sdl2.lib") #pragma comment(lib, "SDL2main.lib") Uint32 audio_len;//音频数据大小 Uint8 *audio_pos;//指向音频数据的指针 /**回调函数(由系统调用) * 函数声明:typedef void (SDLCALL * SDL_AudioCallback) * (void *userdata, Uint8 *

74HC595D特点

心已入冬 提交于 2021-02-13 18:44:27
  74HC595是一个8位串行输入、并行输出的位移缓存器:并行输出为三态输出。在SCK的上升沿,串行数据由SDL输入到内部的8位位移缓存器,并由Q7'输出,而并行输出则是在LCK的上升沿将在8位位移缓存器的数据存入到8位并行输出缓存器。当串行数据输入端OE的控制信号为低使能时,并行输出端的输出值等于并行输出缓存器所存储的值。而当OE为高电位,也就是输出关闭时,并行输出端会维持在高阻抗状态。     74HC595D 特点:   8位串行输入/8位串行或并行输出存储状态寄存器,三种状态   74HC595是具有三态输出功能(即具有高电平、低电平和高阻抗三种输出状态)的门电路。输出寄存器可以直接清除。具有100MHz的移位频率。    74HC595D 特征:   8位串行输入   8位串行或并行输出   具有三态输出的存储寄存器   直接清除移位寄存器   100兆赫(典型)偏移频率   输出能力:   -并行输出;总线驱动器   -串行输出;标准   ICC类别:MSI    74HC595D 应用:   串行到并行数据转换   远程控制保持寄存器    引脚说明:    使用方法:   74595的数据端:   Q0--Q7:八位并行输出端,可以直接控制数码管的8个段。   Q7':级联输出端。将它接下一个595的DS端。   DS:串行数据输入端,级联的话接上一级的Q7'。

Why declare a pointer in SDL before initializing SDL?

╄→尐↘猪︶ㄣ 提交于 2021-02-08 12:12:52
问题 In this code, I see that they declare a pointer before initializing SDL: int main(int argc, char* argv[]) { SDL_Window *window; // Declare a pointer SDL_Init(SDL_INIT_VIDEO); // Initialize SDL2 // Create an application window with the following settings: window = SDL_CreateWindow( "An SDL2 window", // window title SDL_WINDOWPOS_UNDEFINED, // initial x position SDL_WINDOWPOS_UNDEFINED, // initial y position 640, // width, in pixels 480, // height, in pixels SDL_WINDOW_OPENGL // flags - see

VS auto-linking against SDL2 libraries installed with vcpkg on Windows

对着背影说爱祢 提交于 2021-01-29 07:36:04
问题 To the best of my knowledge, this isn't a duplicate of an existing question. This question is specifically about Visual Studio's auto-linking SDL2 libraries. I've installed SDL2 ( x64-windows variant) with vcpkg: vcpkg install sdl2 --triplet x64-windows And I've made vpkg libraries available to Visual Studio: vcpkg integrate install My VS 2019 project is configured to use the Console subsystem, and my main program looks like that: #define SDL_MAIN_HANDLED #include <SDL2/SDL.h> int main(int,

VS auto-linking against SDL2 libraries installed with vcpkg on Windows

北慕城南 提交于 2021-01-29 07:31:29
问题 To the best of my knowledge, this isn't a duplicate of an existing question. This question is specifically about Visual Studio's auto-linking SDL2 libraries. I've installed SDL2 ( x64-windows variant) with vcpkg: vcpkg install sdl2 --triplet x64-windows And I've made vpkg libraries available to Visual Studio: vcpkg integrate install My VS 2019 project is configured to use the Console subsystem, and my main program looks like that: #define SDL_MAIN_HANDLED #include <SDL2/SDL.h> int main(int,

What does SDL_Init exactly do?

你离开我真会死。 提交于 2021-01-29 01:42:51
问题 So, I started using SDL about a year ago, and I just thought SDL_Init initialized SDL's subsytems ( as written here : https://wiki.libsdl.org/SDL_Init ), and that I HAD to call it before anything else. But today, I realized that in a fairly big project, I just forgot to call it, and I never had any problem : everything works perfectly. So I just wonder what it does, since I apparently don't need it to use the library ? 回答1: SDL_Init does indeed initialize the SDL's subsystems. In fact, it

What does SDL_Init exactly do?

感情迁移 提交于 2021-01-29 01:42:42
问题 So, I started using SDL about a year ago, and I just thought SDL_Init initialized SDL's subsytems ( as written here : https://wiki.libsdl.org/SDL_Init ), and that I HAD to call it before anything else. But today, I realized that in a fairly big project, I just forgot to call it, and I never had any problem : everything works perfectly. So I just wonder what it does, since I apparently don't need it to use the library ? 回答1: SDL_Init does indeed initialize the SDL's subsystems. In fact, it

What does SDL_Init exactly do?

随声附和 提交于 2021-01-29 01:40:31
问题 So, I started using SDL about a year ago, and I just thought SDL_Init initialized SDL's subsytems ( as written here : https://wiki.libsdl.org/SDL_Init ), and that I HAD to call it before anything else. But today, I realized that in a fairly big project, I just forgot to call it, and I never had any problem : everything works perfectly. So I just wonder what it does, since I apparently don't need it to use the library ? 回答1: SDL_Init does indeed initialize the SDL's subsystems. In fact, it

What does SDL_Init exactly do?

北战南征 提交于 2021-01-29 01:37:24
问题 So, I started using SDL about a year ago, and I just thought SDL_Init initialized SDL's subsytems ( as written here : https://wiki.libsdl.org/SDL_Init ), and that I HAD to call it before anything else. But today, I realized that in a fairly big project, I just forgot to call it, and I never had any problem : everything works perfectly. So I just wonder what it does, since I apparently don't need it to use the library ? 回答1: SDL_Init does indeed initialize the SDL's subsystems. In fact, it