"Daisy Bell"은 1892년 Harry Dacre 작곡 1961년 IBM 7094는 Daisy Bell 노래를 부르는 최초의 컴퓨터
Channel: Fortran Tutorial
Date: 26/09/2022

"Daisy Bell"은 1892년 Harry Dacre 작곡 
1961년 IBM 7094는 
Daisy Bell 노래를 부르는 
최초의 컴퓨터
보컬 John Kelly,  Carol Lockbaum 
반주 Max Mathews
 
Daisy, Daisy, give me your answer do
데이지, 데이지, 대답해 주세요

I'm half crazy all for the love of you
당신의 사랑에 나는 반쯤 미쳤어요

It won't be a stylish marriage
세련된 결혼은 아닐 거예요

I can't afford a carriage
나는 마차를 살 여유가 없어요

But you'll look sweet upon the seat
Of a bicycle built for two
하지만 당신은 두 사람을 위해 만들어진 
자전거의 좌석에서 달콤해 보일 거예요

#ChatGPT #fortran #coding #DaisyBell
ChatGPT로 짠 Fortran 코딩
program DaisyBell
  implicit none
  integer :: frequency, duration, i
  character(8) :: notes(14) = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'A', 'B', 'A', 'B', 'A', '0', '0']
  integer, parameter :: note_freq(13) = [440, 494, 523, 587, 659, 698, 784, 880, 988, 440, 494, 440, 0, 0]
  integer, parameter :: note_duration(13) = [400, 400, 400, 400, 400, 400, 800, 400, 400, 400, 400, 800, 400, 400]
  
  do i = 1, 14
    frequency = note_freq(i)
    duration = note_duration(i)
    call play_sound(frequency, duration)
    call usleep(200000) ! Wait for 200ms between notes
  end do

contains

  subroutine play_sound(frequency, duration)
    integer, intent(in) :: frequency, duration
    real :: t, dt
    integer :: sample_rate, num_samples, i
    real, dimension(:), allocatable :: signal

    sample_rate = 44100 ! Sample rate in Hz
    num_samples = int(sample_rate * duration / 1000.0)
    dt = 1.0 / real(sample_rate)
    allocate(signal(num_samples))

    do i = 1, num_samples
      t = real(i - 1) * dt
      signal(i) = sin(2.0 * 3.14159 * frequency * t)
    end do

    ! Play the sound (replace with appropriate code for your system)
    call play_audio(signal, sample_rate)

    deallocate(signal)
  end subroutine play_sound

  subroutine play_audio(signal, sample_rate)
    real, dimension(:), intent(in) :: signal
    integer, intent(in) :: sample_rate
    ! Insert code to play audio using your system's audio functions/APIs
  end subroutine play_audio

  subroutine usleep(microseconds)
    integer, intent(in) :: microseconds
    ! Insert code to pause execution for the specified duration
  end subroutine usleep

end program DaisyBell