warmonkey作者
3年7个月前IP:广东
918495
4楼
引用铅球脑袋发表于3楼的内容
不会上chatgpt,  就找到一个opanai的通用AI,不用翻墙。 https://nasaai.xyz/#/home/chat先打听社会上的事情,可是让我很失望,答案都太弱质了。回答简单技术问题...

这一看就是百度做的,百度文库的味道。

我刚试了一下:

Screenshot 2023-03-22 002043.png


Screenshot 2023-03-22 002103.png

Screenshot 2023-03-22 002118.png

#include <c6x.h>
#include <csl.h>
#include <math.h>

#define PI 3.14159265358979323846

/* Initialize PLL */
void initPLL(unsigned int pllm, unsigned int plld, unsigned int pllf)
{
    PLL_CONFIG pllcfg;

    /* Configure PLL */
    pllcfg.PLLM = pllm;
    pllcfg.PLLD = plld;
    pllcfg.PLLF = pllf;
    pllcfg.PLLR = 4;  // Divide system clock by 4
    pllcfg.PLLM2 = 2;
    pllcfg.odiv1_div = 1;
    pllcfg.odiv2_div = 1;

    /* Initialize PLL */
    PLL_init(&pllcfg);

    /* Wait for PLL to lock */
    while (!PLL_locked());
}

/* Initialize DAC */
void initDAC(void)
{
    /* Configure DAC */
    DAC_config(DAC_CHANNEL_BOTH, DAC_FMT_SIGN_MAG, DAC_POL_UNIPOLAR, DAC_REF_INTERNAL, DAC_ALIGN_LEFT);
    DAC_enable(DAC_CHANNEL_BOTH);
}

/* FM Modulation */
void FMModulate(float freqDeviation, float sampleRate, float *inputBuffer, float *outputBuffer, int numSamples)
{
    float phi = 0.0;
    float deltaPhi = 2 * PI * freqDeviation / sampleRate;

    /* FM modulation loop */
    for (int i = 0; i < numSamples; i++) {
        /* Update phase */
        phi += deltaPhi + 2 * PI * inputBuffer[i] / sampleRate;
        if (phi > 2 * PI) {
            phi -= 2 * PI;
        }
        /* Generate modulated output */
        outputBuffer[i] = sinf(phi);
    }
}

int main(void)
{
    float sampleRate = 44100.0;   // Sample rate in Hz
    float freqDeviation = 75000.0;   // Frequency deviation in Hz
    float *inputBuffer, *outputBuffer;
    int numSamples = 1024;

    /* Initialize PLL and DAC */
    initPLL(40, 2, 200);
    initDAC();

    /* Allocate memory for input and output buffers */
    inputBuffer = (float *)malloc(numSamples * sizeof(float));
    outputBuffer = (float *)malloc(numSamples * sizeof(float));

    /* Generate input signal */
    for (int i = 0; i < numSamples; i++) {
        inputBuffer[i] = sinf(2 * PI * 1000.0 * i / sampleRate);
    }

    /* Perform FM modulation */
    FMModulate(freqDeviation, sampleRate, inputBuffer, outputBuffer, numSamples);

    /* Output modulated signal to DAC */
    for (int i = 0; i < numSamples; i++) {
        DAC_write(DAC_CHANNEL_BOTH, outputBuffer[i]);
    }

    /* Free memory */
    free(inputBuffer);
    free(outputBuffer);

    return 0;
}

Screenshot 2023-03-22 002138.png

#define ORDER 1  // Pre-emphasis filter order
#define COEFF 0.95  // Pre-emphasis filter coefficient

float preEmphasisFilter(float x, float *z)
{
    float y;
    y = x + COEFF * z[0];  // Filter equation
    z[0] = x;  // Update filter state
    return y;
}

int main(void)
{
    float x, y, z[ORDER];

    /* Initialize filter state */
    for (int i = 0; i < ORDER; i++) {
        z[i] = 0;
    }

    /* Pre-emphasis loop */
    while (1) {
        /* Read input signal */
        x = readInput();

        /* Apply pre-emphasis filter */
        y = preEmphasisFilter(x, z);

        /* Process output signal */
        processOutput(y);
    }

    return 0;
}

Screenshot 2023-03-22 002147.png

评论
文号 / 918495

万流景仰
名片发私信
学术分 12
总主题 379 帖总回复 8283 楼拥有证书:进士 学者 机友
注册于 2008/10/11 20:04:00最后登录 2026/10/12 22:44:46
主体类型:个人
所属领域:无
认证方式:手机号
IP归属地:0

个人简介

Cubesat

笔记
{{note.content}}
{{n.user.username}}
{{fromNow(n.toc)}} {{n.status === noteStatus.disabled ? "已屏蔽" : ""}} {{n.status === noteStatus.unknown ? "正在审核" : ""}} {{n.status === noteStatus.deleted ? '已删除' : ''}}
  • 编辑
  • 删除
  • {{n.status === 'disabled' ? "解除屏蔽" : "屏蔽" }}
我也是有底线的